From 4c25d57e2f63b31991a2832b990bb0feddf8bce7 Mon Sep 17 00:00:00 2001 From: "FUJI Goro (gfx)" Date: Mon, 14 May 2018 11:52:54 +0900 Subject: [PATCH 001/236] the original classname() accepts boolean, as well as falsy values --- types/classnames/classnames-tests.ts | 3 +++ types/classnames/index.d.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/classnames/classnames-tests.ts b/types/classnames/classnames-tests.ts index b2b8c9eba4..55b801eb40 100644 --- a/types/classnames/classnames-tests.ts +++ b/types/classnames/classnames-tests.ts @@ -38,3 +38,6 @@ const className = cx('foo', ['bar'], { baz: true }); // => "abc def xyz" // falsey values are just ignored cx(null, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1' + +// true is just ignored +cx(true || "foo"); diff --git a/types/classnames/index.d.ts b/types/classnames/index.d.ts index ce2abb5ee3..40e3ce835c 100644 --- a/types/classnames/index.d.ts +++ b/types/classnames/index.d.ts @@ -9,7 +9,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -type ClassValue = string | number | ClassDictionary | ClassArray | undefined | null | false; +type ClassValue = string | number | ClassDictionary | ClassArray | undefined | null | boolean; interface ClassDictionary { [id: string]: boolean | undefined | null; From 27763ecbb2e5883cc047d48b157cb5ee73b566a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Sopy=C5=82o?= Date: Mon, 14 May 2018 10:50:50 +0200 Subject: [PATCH 002/236] [@types/socket.io] fix: socket.use (#24574) --- types/socket.io/index.d.ts | 22 ++++++++++++++++++++++ types/socket.io/socket.io-tests.ts | 9 +++++++++ 2 files changed, 31 insertions(+) diff --git a/types/socket.io/index.d.ts b/types/socket.io/index.d.ts index d63effe544..6f7c0ef321 100644 --- a/types/socket.io/index.d.ts +++ b/types/socket.io/index.d.ts @@ -474,6 +474,21 @@ declare namespace SocketIO { compress( compress: boolean ): Namespace; } + interface Packet extends Array { + /** + * Event name + */ + [0]: string; + /** + * Packet data + */ + [1]: any; + /** + * Ack function + */ + [2]: (...args: any[]) => void; + } + /** * The socket, which handles our connection for a namespace. NOTE: while * we technically extend NodeJS.EventEmitter, we're not putting it here @@ -612,6 +627,13 @@ declare namespace SocketIO { */ in( room: string ): Socket; + /** + * Registers a middleware, which is a function that gets executed for every incoming Packet and receives as parameter the packet and a function to optionally defer execution to the next registered middleware. + * + * Errors passed to middleware callbacks are sent as special error packets to clients. + */ + use( fn: ( packet: Packet, next: (err?: any) => void ) => void ): Socket; + /** * Sends a 'message' event * @see emit( event, ...args ) diff --git a/types/socket.io/socket.io-tests.ts b/types/socket.io/socket.io-tests.ts index 7bfddb1271..60f0d70551 100644 --- a/types/socket.io/socket.io-tests.ts +++ b/types/socket.io/socket.io-tests.ts @@ -180,3 +180,12 @@ function testVolatileServerMessages() { var io = socketIO.listen(80); io.volatile.emit('volatile', 'Lost data'); } + +function testSocketUse() { + var io = socketIO.listen(80); + io.on('connection', (socket) => { + socket.use((packet, next) => { + console.log(packet); + }); + }); +} \ No newline at end of file From 3fbd854b913a1c7ccfde5956eee3cb2a4962846b Mon Sep 17 00:00:00 2001 From: bladegun Date: Mon, 14 May 2018 17:21:40 +0800 Subject: [PATCH 003/236] Added exports of ol.proj object --- types/ol/ol-tests.ts | 2 ++ types/ol/proj/index.d.ts | 3 +++ types/ol/tsconfig.json | 1 + 3 files changed, 6 insertions(+) create mode 100644 types/ol/proj/index.d.ts diff --git a/types/ol/ol-tests.ts b/types/ol/ol-tests.ts index 13a36df6f3..fbfed7e90f 100644 --- a/types/ol/ol-tests.ts +++ b/types/ol/ol-tests.ts @@ -148,6 +148,8 @@ import LayerVectorTile from 'ol/layer/vectortile'; import PointerPointerEvent from 'ol/pointer/pointerevent'; +import Proj from 'ol/proj'; + import ProjProjection from 'ol/proj/projection'; import Rendercanvas from 'ol/render/canvas'; diff --git a/types/ol/proj/index.d.ts b/types/ol/proj/index.d.ts new file mode 100644 index 0000000000..dc8d1a7f95 --- /dev/null +++ b/types/ol/proj/index.d.ts @@ -0,0 +1,3 @@ +import * as ol from 'openlayers'; + +export default ol.proj; diff --git a/types/ol/tsconfig.json b/types/ol/tsconfig.json index 6402adb0f7..79e135476e 100644 --- a/types/ol/tsconfig.json +++ b/types/ol/tsconfig.json @@ -95,6 +95,7 @@ "layer/vector.d.ts", "layer/vectortile.d.ts", "pointer/pointerevent.d.ts", + "proj/index.d.ts", "proj/projection.d.ts", "render/canvas.d.ts", "render/event.d.ts", From 7ebd1ec80e3ad0e92ff2a6b8b73909645c646157 Mon Sep 17 00:00:00 2001 From: Luis Stanley Jovel Date: Mon, 14 May 2018 16:17:53 -0600 Subject: [PATCH 004/236] Add missing property boolean `selfHandleResponse` Add missing boolean property `selfHandleResponse` to ServerOptions interface --- types/http-proxy/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/http-proxy/index.d.ts b/types/http-proxy/index.d.ts index fb7eb26abc..2560b0a38d 100644 --- a/types/http-proxy/index.d.ts +++ b/types/http-proxy/index.d.ts @@ -207,6 +207,8 @@ declare namespace Server { headers?: {[header: string]: string}; /** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */ proxyTimeout?: number; + /** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */ + selfHandleResponse?: boolean; } } From 57bf34b2305e4a345aad418dc0485f7f0601bdc3 Mon Sep 17 00:00:00 2001 From: Damian Bushong Date: Tue, 15 May 2018 09:48:56 -0500 Subject: [PATCH 005/236] Remove User "id" property from oauth2-server typings. This is no longer required as of v2. --- types/oauth2-server/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/oauth2-server/index.d.ts b/types/oauth2-server/index.d.ts index 06b6fbadb0..a4725538fd 100644 --- a/types/oauth2-server/index.d.ts +++ b/types/oauth2-server/index.d.ts @@ -327,7 +327,6 @@ declare namespace OAuth2Server { * A user object is completely transparent to oauth2-server and is simply used as input to model functions. */ interface User { - id: string; [key: string]: any; } From 2050335081cbeb7d449332405e160807c4330dce Mon Sep 17 00:00:00 2001 From: Lauren Budorick Date: Tue, 15 May 2018 17:00:09 -0700 Subject: [PATCH 006/236] Update mapbox-gl definitions --- types/mapbox-gl/index.d.ts | 147 +++++++++++++++++++++++++++++++------ 1 file changed, 123 insertions(+), 24 deletions(-) diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index ece34d0938..16f886c4a1 100644 --- a/types/mapbox-gl/index.d.ts +++ b/types/mapbox-gl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mapbox GL JS v0.44.1 +// Type definitions for Mapbox GL JS v0.45.0 // Project: https://github.com/mapbox/mapbox-gl-js // Definitions by: Dominik Bruderer , Patrick Reames // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -18,6 +18,7 @@ declare namespace mapboxgl { type LngLatBoundsLike = number[][] | LngLatLike[] | LngLatBounds; type PointLike = number[] | Point; type Expression = any[]; + type Anchor = 'center' | 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; /** * Map @@ -33,8 +34,6 @@ declare namespace mapboxgl { removeControl(control: IControl): this; - getClasses(): string[]; - resize(): this; getBounds(): mapboxgl.LngLatBounds; @@ -53,6 +52,12 @@ declare namespace mapboxgl { unproject(point: PointLike): mapboxgl.LngLat; + isMoving(): boolean; + + isZooming(): boolean; + + isRotating(): boolean; + queryRenderedFeatures(pointOrBox?: PointLike | PointLike[], parameters?: { layers?: string[], filter?: any[] }): GeoJSON.Feature[]; querySourceFeatures(sourceID: string, parameters?: { sourceLayer?: string, filter?: any[] }): GeoJSON.Feature[]; @@ -199,9 +204,6 @@ declare namespace mapboxgl { /** initial map center */ center?: LngLatLike; - /** Style class names with which to initialize the map */ - classes?: string[]; - /** ID of the container element */ container?: string | Element; @@ -218,7 +220,7 @@ declare namespace mapboxgl { hash?: boolean; /** If true, map creation will fail if the implementation determines that the performance of the created WebGL context would be dramatically lower than expected. */ - failIfMayorPerformanceCaveat?: boolean; + failIfMajorPerformanceCaveat?: boolean; /** If false, no mouse, touch, or keyboard listeners are attached to the map, so it will not respond to input */ interactive?: boolean; @@ -420,6 +422,8 @@ declare namespace mapboxgl { */ export class ScaleControl extends Control { constructor(options?: { maxWidth?: number, unit?: string }) + + setUnit(unit: 'imperial' | 'metric' | 'nautical'): void; } /** @@ -457,7 +461,7 @@ declare namespace mapboxgl { closeOnClick?: boolean; - anchor?: 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; + anchor?: Anchor; offset?: number | PointLike | { [key: string]: PointLike; }; } @@ -486,8 +490,11 @@ declare namespace mapboxgl { export interface Light { 'anchor'?: 'map' | 'viewport'; 'position'?: number[]; + 'position-transition'?: Transition; 'color'?: string; + 'color-transition'?: Transition; 'intensity'?: number; + 'intensity-transition'?: Transition; } export interface Source { @@ -526,6 +533,8 @@ declare namespace mapboxgl { clusterRadius?: number; clusterMaxZoom?: number; + + lineMetrics?: boolean; } /** @@ -578,7 +587,7 @@ declare namespace mapboxgl { coordinates: number[][]; - canvas: string; + canvas: string | HTMLCanvasElement; getCanvas(): HTMLCanvasElement; @@ -590,7 +599,7 @@ declare namespace mapboxgl { animate?: boolean; - canvas: string; + canvas: string | HTMLCanvasElement; } interface VectorSource extends Source { @@ -738,8 +747,13 @@ declare namespace mapboxgl { static convert(a: PointLike): Point; } + /** + * Marker + */ export class Marker { - constructor(element?: HTMLElement, options?: { offset?: PointLike }); + constructor(options?: mapboxgl.MarkerOptions); + + constructor(element?: HTMLElement, options?: mapboxgl.MarkerOptions); addTo(map: Map): this; @@ -760,6 +774,16 @@ declare namespace mapboxgl { togglePopup(): this; } + export interface MarkerOptions { + element?: HTMLElement; + + offset?: PointLike; + + anchor?: Anchor; + + color?: string + } + /** * Evented */ @@ -773,10 +797,6 @@ declare namespace mapboxgl { off(type?: string | any, layer?: string, listener?: Function): this; once(type: string, listener: Function): this; - - fire(type: string, data?: mapboxgl.EventData | Object): this; - - listens(type: string): boolean; } /** @@ -803,16 +823,20 @@ declare namespace mapboxgl { originalEvent: MouseEvent; point: mapboxgl.Point; lngLat: mapboxgl.LngLat; + preventDefault(): void; + defaultPrevented: boolean; } export class MapTouchEvent { type: string; - target: Map; + map: Map; originalEvent: TouchEvent; point: mapboxgl.Point; lngLat: mapboxgl.LngLat; points: Point[]; lngLats: LngLat[]; + preventDefault(): void; + defaultPrevented: boolean; } export class MapBoxZoomEvent { @@ -825,9 +849,19 @@ declare namespace mapboxgl { dataType: 'source' | 'style' | 'tile'; isSourceLoaded?: boolean; source?: mapboxgl.Source; + sourceDataType?: string; + tile?: any; coord?: any; } + export class MapWheelEvent { + type: string; + map: Map; + originalEvent: MouseEvent; + preventDefault(): void; + defaultPrevented: boolean; + } + /** * AnimationOptions */ @@ -921,11 +955,12 @@ declare namespace mapboxgl { drag?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; dragend?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; pitch?: { data: mapboxgl.EventData }; + wheel?: { data: mapboxgl.MapWheelEvent }; } export interface Layer { id: string; - type?: 'fill' | 'line' | 'symbol' | 'circle' | 'fill-extrusion' | 'raster' | 'background' | 'heatmap'; + type?: 'fill' | 'line' | 'symbol' | 'circle' | 'fill-extrusion' | 'raster' | 'background' | 'heatmap' | 'hillshade'; metadata?: any; ref?: string; @@ -940,8 +975,8 @@ declare namespace mapboxgl { interactive?: boolean; filter?: any[]; - layout?: BackgroundLayout | FillLayout | FillExtrusionLayout | LineLayout | SymbolLayout | RasterLayout | CircleLayout | HeatmapLayout; - paint?: BackgroundPaint | FillPaint | FillExtrusionPaint | LinePaint | SymbolPaint | RasterPaint | CirclePaint | HeatmapPaint; + layout?: BackgroundLayout | FillLayout | FillExtrusionLayout | LineLayout | SymbolLayout | RasterLayout | CircleLayout | HeatmapLayout | HillshadeLayout; + paint?: BackgroundPaint | FillPaint | FillExtrusionPaint | LinePaint | SymbolPaint | RasterPaint | CirclePaint | HeatmapPaint | HillshadePaint; } export interface StyleFunction { @@ -959,8 +994,11 @@ declare namespace mapboxgl { export interface BackgroundPaint { 'background-color'?: string | Expression; + 'background-color-transition'?: Transition; 'background-pattern'?: string; + 'background-pattern-transition'?: Transition; 'background-opacity'?: number | Expression; + 'background-opacity-transition'?: Transition; } export interface FillLayout { @@ -970,11 +1008,16 @@ declare namespace mapboxgl { export interface FillPaint { 'fill-antialias'?: boolean; 'fill-opacity'?: number | StyleFunction | Expression; + 'fill-opacity-transition'?: Transition; 'fill-color'?: string | StyleFunction | Expression; + 'fill-color-transition'?: Transition; 'fill-outline-color'?: string | StyleFunction | Expression; + 'fill-outline-color-transition'?: Transition; 'fill-translate'?: number[] | Expression; + 'fill-translate-transition'?: Transition; 'fill-translate-anchor'?: 'map' | 'viewport'; 'fill-pattern'?: string; + 'fill-pattern-transition'?: Transition; } export interface FillExtrusionLayout { @@ -983,12 +1026,18 @@ declare namespace mapboxgl { export interface FillExtrusionPaint { 'fill-extrusion-opacity'?: number | Expression; + 'fill-extrusion-opacity-transition'?: Transition; 'fill-extrusion-color'?: string | StyleFunction | Expression; + 'fill-extrusion-color-transition'?: Transition; 'fill-extrusion-translate'?: number[] | Expression; + 'fill-extrusion-translate-transition'?: Transition; 'fill-extrusion-translate-anchor'?: 'map' | 'viewport'; 'fill-extrusion-pattern'?: string; + 'fill-extrusion-pattern-transition'?: Transition; 'fill-extrusion-height'?: number | StyleFunction | Expression; + 'fill-extrusion-height-transition'?: Transition; 'fill-extrusion-base'?: number | StyleFunction | Expression; + 'fill-extrusion-base-transition'?: Transition; } export interface LineLayout { @@ -1002,16 +1051,25 @@ declare namespace mapboxgl { export interface LinePaint { 'line-opacity'?: number | StyleFunction | Expression; + 'line-opacity-transition'?: Transition; 'line-color'?: string | StyleFunction | Expression; + 'line-color-transition'?: Transition; 'line-translate'?: number[] | Expression; + 'line-translate-transition'?: Transition; 'line-translate-anchor'?: 'map' | 'viewport'; 'line-width'?: number | StyleFunction | Expression; + 'line-width-transition'?: Transition; 'line-gap-width'?: number | StyleFunction | Expression; + 'line-gap-width-transition'?: Transition; 'line-offset'?: number | StyleFunction | Expression; + 'line-offset-transition'?: Transition; 'line-blur'?: number | StyleFunction | Expression; + 'line-blur-transition'?: Transition; 'line-dasharray'?: number[]; 'line-dasharray-transition'?: Transition; 'line-pattern'?: string; + 'line-pattern-transition'?: Transition; + 'line-gradient'?: Expression; } export interface SymbolLayout { @@ -1024,7 +1082,6 @@ declare namespace mapboxgl { 'icon-ignore-placement'?: boolean; 'icon-optional'?: boolean; 'icon-rotation-alignment'?: 'map' | 'viewport' | 'auto'; - 'icon-pitch-alignment'?: 'map' | 'viewport' | 'auto'; 'icon-size'?: number | StyleFunction | Expression; 'icon-text-fit'?: 'none' | 'both' | 'width' | 'height'; 'icon-text-fit-padding'?: number[] | Expression; @@ -1033,6 +1090,8 @@ declare namespace mapboxgl { 'icon-padding'?: number | Expression; 'icon-keep-upright'?: boolean; 'icon-offset'?: number[] | StyleFunction | Expression; + 'icon-anchor'?: Anchor; + 'icon-pitch-alignment'?: 'map' | 'viewport' | 'auto'; 'text-pitch-alignment'?: 'map' | 'viewport' | 'auto'; 'text-rotation-alignment'?: 'map' | 'viewport' | 'auto'; 'text-field'?: string | StyleFunction; @@ -1042,7 +1101,7 @@ declare namespace mapboxgl { 'text-line-height'?: number | Expression; 'text-letter-spacing'?: number | Expression; 'text-justify'?: 'left' | 'center' | 'right'; - 'text-anchor'?: 'center' | 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; + 'text-anchor'?: Anchor; 'text-max-angle'?: number | Expression; 'text-rotate'?: number | StyleFunction | Expression; 'text-padding'?: number | Expression; @@ -1052,23 +1111,34 @@ declare namespace mapboxgl { 'text-allow-overlap'?: boolean; 'text-ignore-placement'?: boolean; 'text-optional'?: boolean; - } export interface SymbolPaint { 'icon-opacity'?: number | StyleFunction | Expression; + 'icon-opacity-transition'?: Transition; 'icon-color'?: string | StyleFunction | Expression; + 'icon-color-transition'?: Transition; 'icon-halo-color'?: string | StyleFunction | Expression; + 'icon-halo-color-transition'?: Transition; 'icon-halo-width'?: number | StyleFunction | Expression; + 'icon-halo-width-transition'?: Transition; 'icon-halo-blur'?: number | StyleFunction | Expression; + 'icon-halo-blur-transition'?: Transition; 'icon-translate'?: number[] | Expression; + 'icon-translate-transition'?: Transition; 'icon-translate-anchor'?: 'map' | 'viewport'; 'text-opacity'?: number | StyleFunction | Expression; + 'text-opacity-transition'?: Transition; 'text-color'?: string | StyleFunction | Expression; + 'text-color-transition'?: Transition; 'text-halo-color'?: string | StyleFunction | Expression; + 'text-halo-color-transition'?: Transition; 'text-halo-width'?: number | StyleFunction | Expression; + 'text-halo-width-transition'?: Transition; 'text-halo-blur'?: number | StyleFunction | Expression; + 'text-halo-blur-transition'?: Transition; 'text-translate'?: number[] | Expression; + 'text-translate-transition'?: Transition; 'text-translate-anchor'?: 'map' | 'viewport'; } @@ -1078,11 +1148,17 @@ declare namespace mapboxgl { export interface RasterPaint { 'raster-opacity'?: number | Expression; + 'raster-opacity-transition'?: Transition; 'raster-hue-rotate'?: number | Expression; + 'raster-hue-rotate-transition'?: Transition; 'raster-brightness-min'?: number | Expression; + 'raster-brightness-min-transition'?: Transition; 'raster-brightness-max'?: number | Expression; + 'raster-brightness-max-transition'?: Transition; 'raster-saturation'?: number | Expression; + 'raster-saturation-transition'?: Transition; 'raster-contrast'?: number | Expression; + 'raster-contrast-transition'?: Transition; 'raster-fade-duration'?: number | Expression; } @@ -1094,16 +1170,22 @@ declare namespace mapboxgl { 'circle-radius'?: number | StyleFunction | Expression; 'circle-radius-transition'?: Transition; 'circle-color'?: string | StyleFunction | Expression; + 'circle-color-transition'?: Transition; 'circle-blur'?: number | StyleFunction | Expression; + 'circle-blur-transition'?: Transition; 'circle-opacity'?: number | StyleFunction | Expression; 'circle-opacity-transition'?: Transition; 'circle-translate'?: number[] | Expression; + 'circle-translate-transition'?: Transition; 'circle-translate-anchor'?: 'map' | 'viewport'; 'circle-pitch-scale'?: 'map' | 'viewport'; 'circle-pitch-alignment'?: 'map' | 'viewport'; 'circle-stroke-width'?: number | StyleFunction | Expression; + 'circle-stroke-width-transition'?: Transition; 'circle-stroke-color'?: string | StyleFunction | Expression; + 'circle-stroke-color-transition'?: Transition; 'circle-stroke-opacity'?: number | StyleFunction | Expression; + 'circle-stroke-opacity-transition'?: Transition; } export interface HeatmapLayout { @@ -1112,14 +1194,31 @@ declare namespace mapboxgl { export interface HeatmapPaint { 'heatmap-radius'?: number | Expression; - 'heatmap-transition'?: Transition; + 'heatmap-radius-transition'?: Transition; 'heatmap-weight'?: number | StyleFunction | Expression; 'heatmap-intensity'?: number | Expression; + 'heatmap-intensity-transition'?: Transition; 'heatmap-color'?: string | Expression; - 'heatmap-color-transition'?: Transition; 'heatmap-opacity'?: number | Expression; 'heatmap-opacity-transition'?: Transition; } + + export interface HillshadeLayout { + visibility?: 'visible' | 'none'; + } + + export interface HillshadePaint { + 'hillshade-illumination-direction'?: number | Expression; + 'hillshade-illumination-anchor'?: 'map' | 'viewport'; + 'hillshade-exaggeration'?: number | Expression; + 'hillshade-exaggeration-transition'?: Transition; + 'hillshade-shadow-color'?: string | Expression; + 'hillshade-shadow-color-transition'?: Transition; + 'hillshade-highlight-color'?: string | Expression; + 'hillshade-highlight-color-transition'?: Transition; + 'hillshade-accent-color'?: string | Expression; + 'hillshade-accent-color-transition'?: Transition; + } } declare module 'mapbox-gl' { From b31d9543ea371e290f6e771fec4dd5cca9250abd Mon Sep 17 00:00:00 2001 From: "rheese.burgess" Date: Wed, 16 May 2018 12:57:33 +0100 Subject: [PATCH 007/236] [matter.js] Added damping to constraints --- types/matter-js/index.d.ts | 28 +++++++++++++++++++++++++++- types/matter-js/matter-js-tests.ts | 3 ++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/types/matter-js/index.d.ts b/types/matter-js/index.d.ts index ffca8627d0..4275785191 100644 --- a/types/matter-js/index.d.ts +++ b/types/matter-js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Matter.js - 0.10.0 +// Type definitions for Matter.js - 0.10.1 // Project: https://github.com/liabru/matter-js // Definitions by: Ivane Gegia , // David Asmuth , @@ -1629,6 +1629,19 @@ declare namespace Matter { */ stiffness?: number; + /** + * A `Number` that specifies the damping of the constraint, + * i.e. the amount of resistance applied to each body based on their velocities to limit the amount of oscillation. + * Damping will only be apparent when the constraint also has a very low `stiffness`. + * A value of `0.1` means the constraint will apply heavy damping, resulting in little to no oscillation. + * A value of `0` means the constraint will apply no damping. + * + * @property damping + * @type number + * @default 0 + */ + damping?: number; + /** * A `String` denoting the type of object. * @@ -1772,6 +1785,19 @@ declare namespace Matter { */ stiffness: number; + /** + * A `Number` that specifies the damping of the constraint, + * i.e. the amount of resistance applied to each body based on their velocities to limit the amount of oscillation. + * Damping will only be apparent when the constraint also has a very low `stiffness`. + * A value of `0.1` means the constraint will apply heavy damping, resulting in little to no oscillation. + * A value of `0` means the constraint will apply no damping. + * + * @property damping + * @type number + * @default 0 + */ + damping: number; + /** * A `String` denoting the type of object. * diff --git a/types/matter-js/matter-js-tests.ts b/types/matter-js/matter-js-tests.ts index 3c34f91ecc..d5dca7e50b 100644 --- a/types/matter-js/matter-js-tests.ts +++ b/types/matter-js/matter-js-tests.ts @@ -42,7 +42,8 @@ World.add(engine.world, stack); var constraint1 = Constraint.create({ bodyA: box1, bodyB: box2, - stiffness: 0.02 + stiffness: 0.02, + damping: 0.01 }); //Query From f7c46ccc76f00e236043fcb5dd8344448d7896cf Mon Sep 17 00:00:00 2001 From: Niklas Lindgren Date: Wed, 16 May 2018 15:33:16 +0100 Subject: [PATCH 008/236] style: prettier format --- types/node-fetch/index.d.ts | 180 ++++++++++++++++++++++-------------- 1 file changed, 110 insertions(+), 70 deletions(-) diff --git a/types/node-fetch/index.d.ts b/types/node-fetch/index.d.ts index 874e216e89..02f1c8500e 100644 --- a/types/node-fetch/index.d.ts +++ b/types/node-fetch/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for node-fetch v1.6 +// Type definitions for node-fetch v2.1.2 // Project: https://github.com/bitinn/node-fetch // Definitions by: Torsten Werner +// Niklas Lindgren // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -8,103 +9,142 @@ import { Agent } from "http"; export class Request extends Body { - constructor(input: string | Request, init?: RequestInit); - method: string; - url: string; - headers: Headers; - context: RequestContext; - referrer: string; - redirect: RequestRedirect; + constructor(input: string | Request, init?: RequestInit); + method: string; + url: string; + headers: Headers; + context: RequestContext; + referrer: string; + redirect: RequestRedirect; - //node-fetch extensions to the whatwg/fetch spec - compress: boolean; - agent?: Agent; - counter: number; - follow: number; - hostname: string; - protocol: string; - port?: number; - timeout: number; - size: number; + //node-fetch extensions to the whatwg/fetch spec + compress: boolean; + agent?: Agent; + counter: number; + follow: number; + hostname: string; + protocol: string; + port?: number; + timeout: number; + size: number; } interface RequestInit { - //whatwg/fetch standard options - method?: string; - headers?: HeaderInit | { [index: string]: string }; - body?: BodyInit; - redirect?: RequestRedirect; + //whatwg/fetch standard options + method?: string; + headers?: HeaderInit | { [index: string]: string }; + body?: BodyInit; + redirect?: RequestRedirect; - //node-fetch extensions - timeout?: number; //=0 req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies) - compress?: boolean; //=true support gzip/deflate content encoding. false to disable - size?: number; //=0 maximum response body size in bytes. 0 to disable - agent?: Agent; //=null http.Agent instance, allows custom proxy, certificate etc. - follow?: number; //=20 maximum redirect count. 0 to not follow redirect + //node-fetch extensions + timeout?: number; //=0 req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies) + compress?: boolean; //=true support gzip/deflate content encoding. false to disable + size?: number; //=0 maximum response body size in bytes. 0 to disable + agent?: Agent; //=null http.Agent instance, allows custom proxy, certificate etc. + follow?: number; //=20 maximum redirect count. 0 to not follow redirect - //node-fetch does not support mode, cache or credentials options + //node-fetch does not support mode, cache or credentials options } type RequestContext = - "audio" | "beacon" | "cspreport" | "download" | "embed" | - "eventsource" | "favicon" | "fetch" | "font" | "form" | "frame" | - "hyperlink" | "iframe" | "image" | "imageset" | "import" | - "internal" | "location" | "manifest" | "object" | "ping" | "plugin" | - "prefetch" | "script" | "serviceworker" | "sharedworker" | - "subresource" | "style" | "track" | "video" | "worker" | - "xmlhttprequest" | "xslt"; + | "audio" + | "beacon" + | "cspreport" + | "download" + | "embed" + | "eventsource" + | "favicon" + | "fetch" + | "font" + | "form" + | "frame" + | "hyperlink" + | "iframe" + | "image" + | "imageset" + | "import" + | "internal" + | "location" + | "manifest" + | "object" + | "ping" + | "plugin" + | "prefetch" + | "script" + | "serviceworker" + | "sharedworker" + | "subresource" + | "style" + | "track" + | "video" + | "worker" + | "xmlhttprequest" + | "xslt"; type RequestMode = "same-origin" | "no-cors" | "cors"; type RequestRedirect = "follow" | "error" | "manual"; type RequestCredentials = "omit" | "same-origin" | "include"; type RequestCache = - "default" | "no-store" | "reload" | "no-cache" | - "force-cache" | "only-if-cached"; + | "default" + | "no-store" + | "reload" + | "no-cache" + | "force-cache" + | "only-if-cached"; export class Headers { - append(name: string, value: string): void; - delete(name: string): void; - get(name: string): string | null; - getAll(name: string): Array; - has(name: string): boolean; - set(name: string, value: string): void; - forEach(callback: (value: string, name: string) => void): void; + append(name: string, value: string): void; + delete(name: string): void; + get(name: string): string | null; + getAll(name: string): Array; + has(name: string): boolean; + set(name: string, value: string): void; + forEach(callback: (value: string, name: string) => void): void; } export class Body { - bodyUsed: boolean; - body: NodeJS.ReadableStream; - json(): Promise; - json(): Promise; - text(): Promise; - buffer(): Promise; - arrayBuffer(): Promise; + bodyUsed: boolean; + body: NodeJS.ReadableStream; + json(): Promise; + json(): Promise; + text(): Promise; + buffer(): Promise; + arrayBuffer(): Promise; } export class Response extends Body { - constructor(body?: BodyInit, init?: ResponseInit); - static error(): Response; - static redirect(url: string, status: number): Response; - type: ResponseType; - url: string; - status: number; - ok: boolean; - size: number; - statusText: string; - timeout: number; - headers: Headers; - clone(): Response; + constructor(body?: BodyInit, init?: ResponseInit); + static error(): Response; + static redirect(url: string, status: number): Response; + type: ResponseType; + url: string; + status: number; + ok: boolean; + size: number; + statusText: string; + timeout: number; + headers: Headers; + clone(): Response; } -type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; +type ResponseType = + | "basic" + | "cors" + | "default" + | "error" + | "opaque" + | "opaqueredirect"; interface ResponseInit { - status: number; - statusText?: string; - headers?: HeaderInit; + status: number; + statusText?: string; + headers?: HeaderInit; } type HeaderInit = Headers | Array; type BodyInit = ArrayBuffer | ArrayBufferView | string | NodeJS.ReadableStream; type RequestInfo = Request | string; -export default function fetch(url: string | Request, init?: RequestInit): Promise; +export default function fetch( + url: string | Request, + init?: RequestInit +): Promise; From eba02ef3a0e4a407d3e5402ad6824d0ad26ddaf4 Mon Sep 17 00:00:00 2001 From: Niklas Lindgren Date: Wed, 16 May 2018 15:34:07 +0100 Subject: [PATCH 009/236] feat: add missing methods on Headers --- types/node-fetch/index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/node-fetch/index.d.ts b/types/node-fetch/index.d.ts index 02f1c8500e..d6e76a3bad 100644 --- a/types/node-fetch/index.d.ts +++ b/types/node-fetch/index.d.ts @@ -91,7 +91,8 @@ type RequestCache = | "force-cache" | "only-if-cached"; -export class Headers { +export class Headers implements Iterable<[string, string]> { + constructor(init?: Headers | { [k: string]: string }); append(name: string, value: string): void; delete(name: string): void; get(name: string): string | null; @@ -99,6 +100,11 @@ export class Headers { has(name: string): boolean; set(name: string, value: string): void; forEach(callback: (value: string, name: string) => void): void; + keys(): Iterator; + entries(): Iterator<[string, string]>; + values(): Iterator<[string]>; + raw(): { [k: string]: string }; + [Symbol.iterator](): Iterator<[string, string]>; } export class Body { From 2cbe57ed327e4ff0e531250e3375c3ade02e9209 Mon Sep 17 00:00:00 2001 From: Niklas Lindgren Date: Wed, 16 May 2018 16:08:45 +0100 Subject: [PATCH 010/236] feat: add Blob definition --- types/node-fetch/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/node-fetch/index.d.ts b/types/node-fetch/index.d.ts index d6e76a3bad..a173d08aaa 100644 --- a/types/node-fetch/index.d.ts +++ b/types/node-fetch/index.d.ts @@ -107,6 +107,12 @@ export class Headers implements Iterable<[string, string]> { [Symbol.iterator](): Iterator<[string, string]>; } +export class Blob { + type: string; + size: number; + slice(start?: number, end?: number): Blob; +} + export class Body { bodyUsed: boolean; body: NodeJS.ReadableStream; From 505f5955af254d1d1c3beea163c4a6021cf4716a Mon Sep 17 00:00:00 2001 From: Niklas Lindgren Date: Wed, 16 May 2018 15:48:30 +0100 Subject: [PATCH 011/236] feat: add FetchError defintion --- types/node-fetch/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/node-fetch/index.d.ts b/types/node-fetch/index.d.ts index a173d08aaa..98ccbde8fe 100644 --- a/types/node-fetch/index.d.ts +++ b/types/node-fetch/index.d.ts @@ -123,6 +123,11 @@ export class Body { arrayBuffer(): Promise; } +export class FetchError extends Error { + name: "FetchError"; + constructor(message: string, type: string, systemError: string); +} + export class Response extends Body { constructor(body?: BodyInit, init?: ResponseInit); static error(): Response; From 7074864dbdcbd644e065fa793a7cd6a1bbb16c92 Mon Sep 17 00:00:00 2001 From: Niklas Lindgren Date: Wed, 16 May 2018 15:51:20 +0100 Subject: [PATCH 012/236] feat: amend Request definition --- types/node-fetch/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/node-fetch/index.d.ts b/types/node-fetch/index.d.ts index 98ccbde8fe..5c9c8c3741 100644 --- a/types/node-fetch/index.d.ts +++ b/types/node-fetch/index.d.ts @@ -9,13 +9,14 @@ import { Agent } from "http"; export class Request extends Body { - constructor(input: string | Request, init?: RequestInit); + constructor(input: string | { href: string } | Request, init?: RequestInit); method: string; url: string; headers: Headers; context: RequestContext; referrer: string; redirect: RequestRedirect; + clone(): Request; //node-fetch extensions to the whatwg/fetch spec compress: boolean; From b635ffe8a70097f8b8bcd669959fcfb520148d7c Mon Sep 17 00:00:00 2001 From: Niklas Lindgren Date: Wed, 16 May 2018 16:12:58 +0100 Subject: [PATCH 013/236] feat: amend Body definition --- types/node-fetch/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/node-fetch/index.d.ts b/types/node-fetch/index.d.ts index 5c9c8c3741..dc11802c76 100644 --- a/types/node-fetch/index.d.ts +++ b/types/node-fetch/index.d.ts @@ -115,11 +115,14 @@ export class Blob { } export class Body { + constructor(body?: any, opts?: { size?: number; timeout?: number }); + blob(): Promise; bodyUsed: boolean; body: NodeJS.ReadableStream; json(): Promise; json(): Promise; text(): Promise; + textConverted(): Promise; buffer(): Promise; arrayBuffer(): Promise; } From 61b2726389e292245ec5c9f20c6da403898fd378 Mon Sep 17 00:00:00 2001 From: Niklas Lindgren Date: Wed, 16 May 2018 16:15:28 +0100 Subject: [PATCH 014/236] style: sort methods and union members in alphabetical order --- types/node-fetch/index.d.ts | 81 +++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/types/node-fetch/index.d.ts b/types/node-fetch/index.d.ts index dc11802c76..57c752d55e 100644 --- a/types/node-fetch/index.d.ts +++ b/types/node-fetch/index.d.ts @@ -10,39 +10,39 @@ import { Agent } from "http"; export class Request extends Body { constructor(input: string | { href: string } | Request, init?: RequestInit); - method: string; - url: string; - headers: Headers; - context: RequestContext; - referrer: string; - redirect: RequestRedirect; clone(): Request; + context: RequestContext; + headers: Headers; + method: string; + redirect: RequestRedirect; + referrer: string; + url: string; //node-fetch extensions to the whatwg/fetch spec - compress: boolean; agent?: Agent; + compress: boolean; counter: number; follow: number; hostname: string; - protocol: string; port?: number; - timeout: number; + protocol: string; size: number; + timeout: number; } interface RequestInit { //whatwg/fetch standard options - method?: string; - headers?: HeaderInit | { [index: string]: string }; body?: BodyInit; + headers?: HeaderInit | { [index: string]: string }; + method?: string; redirect?: RequestRedirect; //node-fetch extensions - timeout?: number; //=0 req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies) - compress?: boolean; //=true support gzip/deflate content encoding. false to disable - size?: number; //=0 maximum response body size in bytes. 0 to disable agent?: Agent; //=null http.Agent instance, allows custom proxy, certificate etc. + compress?: boolean; //=true support gzip/deflate content encoding. false to disable follow?: number; //=20 maximum redirect count. 0 to not follow redirect + size?: number; //=0 maximum response body size in bytes. 0 to disable + timeout?: number; //=0 req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies) //node-fetch does not support mode, cache or credentials options } @@ -74,37 +74,40 @@ type RequestContext = | "script" | "serviceworker" | "sharedworker" - | "subresource" | "style" + | "subresource" | "track" | "video" | "worker" | "xmlhttprequest" | "xslt"; -type RequestMode = "same-origin" | "no-cors" | "cors"; -type RequestRedirect = "follow" | "error" | "manual"; -type RequestCredentials = "omit" | "same-origin" | "include"; +type RequestMode = "cors" | "no-cors" | "same-origin"; +type RequestRedirect = "error" | "follow" | "manual"; +type RequestCredentials = "omit" | "include" | "same-origin"; + type RequestCache = | "default" - | "no-store" - | "reload" - | "no-cache" | "force-cache" - | "only-if-cached"; + | "no-cache" + | "no-store" + | "only-if-cached" + | "reload"; export class Headers implements Iterable<[string, string]> { constructor(init?: Headers | { [k: string]: string }); + forEach(callback: (value: string, name: string) => void): void; append(name: string, value: string): void; delete(name: string): void; get(name: string): string | null; getAll(name: string): Array; has(name: string): boolean; - set(name: string, value: string): void; - forEach(callback: (value: string, name: string) => void): void; - keys(): Iterator; - entries(): Iterator<[string, string]>; - values(): Iterator<[string]>; raw(): { [k: string]: string }; + set(name: string, value: string): void; + + // Iterator methods + entries(): Iterator<[string, string]>; + keys(): Iterator; + values(): Iterator<[string]>; [Symbol.iterator](): Iterator<[string, string]>; } @@ -116,15 +119,15 @@ export class Blob { export class Body { constructor(body?: any, opts?: { size?: number; timeout?: number }); + arrayBuffer(): Promise; blob(): Promise; - bodyUsed: boolean; body: NodeJS.ReadableStream; + bodyUsed: boolean; + buffer(): Promise; json(): Promise; json(): Promise; text(): Promise; textConverted(): Promise; - buffer(): Promise; - arrayBuffer(): Promise; } export class FetchError extends Error { @@ -136,15 +139,15 @@ export class Response extends Body { constructor(body?: BodyInit, init?: ResponseInit); static error(): Response; static redirect(url: string, status: number): Response; - type: ResponseType; - url: string; - status: number; + clone(): Response; + headers: Headers; ok: boolean; size: number; + status: number; statusText: string; timeout: number; - headers: Headers; - clone(): Response; + type: ResponseType; + url: string; } type ResponseType = @@ -156,14 +159,14 @@ type ResponseType = | "opaqueredirect"; interface ResponseInit { + headers?: HeaderInit; status: number; statusText?: string; - headers?: HeaderInit; } -type HeaderInit = Headers | Array; -type BodyInit = ArrayBuffer | ArrayBufferView | string | NodeJS.ReadableStream; -type RequestInfo = Request | string; +type HeaderInit = Array | Headers; +type BodyInit = ArrayBuffer | ArrayBufferView | NodeJS.ReadableStream | string; +type RequestInfo = string | Request; export default function fetch( url: string | Request, From 956fe591b8c118cbfd4c0303df7fd29c08939481 Mon Sep 17 00:00:00 2001 From: Niklas Lindgren Date: Wed, 16 May 2018 16:26:19 +0100 Subject: [PATCH 015/236] style: drop leading pipe in union for compat with TS2.0 --- types/node-fetch/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/node-fetch/index.d.ts b/types/node-fetch/index.d.ts index 57c752d55e..47638e382f 100644 --- a/types/node-fetch/index.d.ts +++ b/types/node-fetch/index.d.ts @@ -48,7 +48,7 @@ interface RequestInit { } type RequestContext = - | "audio" + "audio" | "beacon" | "cspreport" | "download" @@ -86,7 +86,7 @@ type RequestRedirect = "error" | "follow" | "manual"; type RequestCredentials = "omit" | "include" | "same-origin"; type RequestCache = - | "default" + "default" | "force-cache" | "no-cache" | "no-store" @@ -151,7 +151,7 @@ export class Response extends Body { } type ResponseType = - | "basic" + "basic" | "cors" | "default" | "error" From 1405d1c6197e1cc8ee178b6f19b79903cd7ff9fe Mon Sep 17 00:00:00 2001 From: Evghenii Vasilovici Date: Thu, 17 May 2018 10:26:56 +0200 Subject: [PATCH 016/236] Change result type of `columns()` and `tables()` callback definition of `Database`. Add `ODBCResult.fetchSync()` definition --- types/ibm_db/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/ibm_db/index.d.ts b/types/ibm_db/index.d.ts index de54b9ca26..24699c195e 100644 --- a/types/ibm_db/index.d.ts +++ b/types/ibm_db/index.d.ts @@ -104,9 +104,9 @@ export class Database implements Options { rollbackTransactionSync(): Database; - columns(catalog: string | null, schema: string | null, table: string | null, column: string | null, cb: (error: Error, res: ODBCResult) => void): void; + columns(catalog: string | null, schema: string | null, table: string | null, column: string | null, cb: (error: Error, res: any[]) => void): void; - tables(catalog: string | null, schema: string | null, table: string | null, type: string | null, cb: (error: Error, res: ODBCResult) => void): void; + tables(catalog: string | null, schema: string | null, table: string | null, type: string | null, cb: (error: Error, res: any[]) => void): void; describe(obj: DescribeObject, cb: (error: Error, res: any[]) => void): void; @@ -187,6 +187,7 @@ export class ODBCStatement { export class ODBCResult { fetchMode: number; + fetchSync(): any[]; fetchAllSync(): any[]; moreResultsSync(): any[]; closeSync(): void; From fcd0b6a6b626752b3c99fe467398d419d72cae23 Mon Sep 17 00:00:00 2001 From: Nick Burrell Date: Thu, 17 May 2018 10:51:48 +0100 Subject: [PATCH 017/236] Added StyleFunction to SymbolLayout - icon-allow-overlap --- types/mapbox-gl/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index ece34d0938..d8362a14d8 100644 --- a/types/mapbox-gl/index.d.ts +++ b/types/mapbox-gl/index.d.ts @@ -1020,7 +1020,7 @@ declare namespace mapboxgl { 'symbol-placement'?: 'point' | 'line'; 'symbol-spacing'?: number | Expression; 'symbol-avoid-edges'?: boolean; - 'icon-allow-overlap'?: boolean; + 'icon-allow-overlap'?: boolean | StyleFunction; 'icon-ignore-placement'?: boolean; 'icon-optional'?: boolean; 'icon-rotation-alignment'?: 'map' | 'viewport' | 'auto'; From ef1a48d2b220485a52437d332f82e6784befae85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Magrin?= Date: Thu, 17 May 2018 14:36:47 +0200 Subject: [PATCH 018/236] Try to update type definition to new version of react-navigation 2.0.1 --- types/react-navigation/index.d.ts | 477 +++++++++++++++++++----------- 1 file changed, 303 insertions(+), 174 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 1233ca39e3..641dd8463f 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-navigation 1.5 +// Type definitions for react-navigation 2.0.1 // Project: https://github.com/react-navigation/react-navigation // Definitions by: Huhuanming // mhcgrq @@ -16,11 +16,12 @@ // Armando Assuncao // Ciaran Liedeman // Edward Sammut Alessi +// Jeremy Magrin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 /** - * Reference: https://github.com/react-navigation/react-navigation/tree/3f3ef6485c8932f49fddc3dd2c508629110bf2b6 + * Reference: https://github.com/react-navigation/react-navigation/tree/a37473c5e4833f48796ee6c7c9cb4a8ac49d9c06 * * NOTE: Please update the commit/link above when updating to a new Flow * react-navigation/flow/react-navigation.js reference, so we can conveniently just look at diffs on @@ -43,15 +44,21 @@ export type AnimatedValue = any; export type HeaderMode = 'float' | 'screen' | 'none'; +export interface HeaderForceInset { + horizontal?: string; + vertical?: string, + left?: string, + right?: string, + top?: string, + bottom?: string, +} + export interface HeaderProps extends NavigationSceneRendererProps { mode: HeaderMode; - router: NavigationRouter< - NavigationState, - NavigationStackScreenOptions - >; - getScreenDetails: (navigationScene: NavigationScene) => NavigationScreenDetails< - NavigationStackScreenOptions - >; + router: NavigationRouter; + getScreenDetails: ( + navigationScene: NavigationScene + ) => NavigationScreenDetails; style: StyleProp; } @@ -76,7 +83,9 @@ export interface NavigationState { routes: any[]; } -export type NavigationRoute = NavigationLeafRoute | NavigationStateRoute; +export type NavigationRoute = + | NavigationLeafRoute + | NavigationStateRoute; export interface NavigationLeafRoute { /** @@ -100,7 +109,9 @@ export interface NavigationLeafRoute { params?: Params; } -export type NavigationStateRoute = NavigationLeafRoute & NavigationState; +export type NavigationStateRoute< + NavigationLeafRouteParams + > = NavigationLeafRoute & NavigationState; export type NavigationScreenOptionsGetter = ( navigation: NavigationScreenProp>, @@ -113,7 +124,10 @@ export interface NavigationRouter { * an optional previous state. When the action is considered handled but the * state is unchanged, the output state is null. */ - getStateForAction: (action: NavigationAction, lastState?: State) => (State | null); + getStateForAction: ( + action: NavigationAction, + lastState?: State + ) => State | null; /** * Maps a URI-like string to an action. This can be mapped to a state @@ -122,14 +136,14 @@ export interface NavigationRouter { getActionForPathAndParams: ( path: string, params?: NavigationParams - ) => (NavigationAction | null); + ) => NavigationAction | null; getPathAndParamsForState: ( state: State ) => { - path: string, - params?: NavigationParams, - }; + path: string; + params?: NavigationParams; + }; getComponentForRouteName: (routeName: string) => NavigationComponent; @@ -147,11 +161,8 @@ export interface NavigationRouter { } export type NavigationScreenOption = - T - | (( - navigation: NavigationScreenProp, - config: T - ) => T); + | T + | ((navigation: NavigationScreenProp, config: T) => T); export interface NavigationScreenDetails { options: T; @@ -159,7 +170,9 @@ export interface NavigationScreenDetails { navigation: NavigationScreenProp; } -export type NavigationScreenOptions = NavigationStackScreenOptions & NavigationTabScreenOptions & NavigationDrawerScreenOptions; +export type NavigationScreenOptions = NavigationStackScreenOptions & + NavigationTabScreenOptions & + NavigationDrawerScreenOptions; export interface NavigationScreenConfigProps { navigation: NavigationScreenProp; @@ -167,30 +180,34 @@ export interface NavigationScreenConfigProps { } export type NavigationScreenConfig = - Options - | ((navigationOptionsContainer: NavigationScreenConfigProps & { - navigationOptions: NavigationScreenProp, - }) => Options); + | Options + | (( + navigationOptionsContainer: NavigationScreenConfigProps & { + navigationOptions: NavigationScreenProp; + } + ) => Options); export type NavigationComponent = - NavigationScreenComponent - | NavigationNavigator; + | NavigationScreenComponent + | NavigationNavigator + | any; export type NavigationScreenComponent< - Params = NavigationParams, - Options = {}, - Props = {} -> = React.ComponentType & Props> & -{ navigationOptions?: NavigationScreenConfig }; + Params = NavigationParams, + Options = {}, + Props = {} + > = React.ComponentType & Props> & { + navigationOptions?: NavigationScreenConfig; + }; export type NavigationNavigator< - State = NavigationState, - Options = {}, - Props = {} -> = React.ComponentType & Props> & { - router: NavigationRouter, - navigationOptions?: NavigationScreenConfig, -}; + State = NavigationState, + Options = {}, + Props = {} + > = React.ComponentType & Props> & { + router: NavigationRouter; + navigationOptions?: NavigationScreenConfig; + }; export interface NavigationParams { [key: string]: any; @@ -206,7 +223,8 @@ export interface NavigationNavigateActionPayload { key?: string; } -export interface NavigationNavigateAction extends NavigationNavigateActionPayload { +export interface NavigationNavigateAction + extends NavigationNavigateActionPayload { type: 'Navigation/NAVIGATE'; } @@ -226,7 +244,8 @@ export interface NavigationSetParamsActionPayload { params?: NavigationParams; } -export interface NavigationSetParamsAction extends NavigationSetParamsActionPayload { +export interface NavigationSetParamsAction + extends NavigationSetParamsActionPayload { type: 'Navigation/SET_PARAMS'; } @@ -271,40 +290,69 @@ export interface NavigationPopToTopActionPayload { immediate?: boolean; } -export interface NavigationPopToTopAction extends NavigationPopToTopActionPayload { +export interface NavigationPopToTopAction + extends NavigationPopToTopActionPayload { type: 'Navigation/POP_TO_TOP'; } export interface NavigationStackViewConfig { mode?: 'card' | 'modal'; headerMode?: HeaderMode; + headerTransitionPreset?: 'fade-in-place' | 'uikit'; cardStyle?: StyleProp; transitionConfig?: ( transitionProps: NavigationTransitionProps, prevTransitionProps: NavigationTransitionProps, - isModal: boolean, + isModal: boolean ) => TransitionConfig; - onTransitionStart?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => Promise | void; - onTransitionEnd?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => void; + onTransitionStart?: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps?: NavigationTransitionProps + ) => Promise | void; + onTransitionEnd?: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps?: NavigationTransitionProps + ) => void; +} + +/** + * Switch Navigator + */ + +export interface NavigationSwitchRouterConfig { + initialRouteName?: string; + initialRouteParams?: NavigationParams; + paths?: NavigationPathsConfig; + navigationOptions?: NavigationScreenConfig; + order?: string[]; + backBehavior?: 'none' | 'initialRoute'; // defaults to `'none'` + resetOnBlur?: boolean; // defaults to `true` } export interface NavigationStackScreenOptions { title?: string; - header?: (React.ReactElement | ((headerProps: HeaderProps) => React.ReactElement)) | null; + header?: + | ( + | React.ReactElement + | ((headerProps: HeaderProps) => React.ReactElement)) + | null; headerTransparent?: boolean; headerTitle?: string | React.ReactElement; headerTitleStyle?: StyleProp; headerTintColor?: string; headerLeft?: React.ReactElement; headerBackTitle?: string | null; + headerBackImage?: React.ReactElement; headerTruncatedBackTitle?: string; headerBackTitleStyle?: StyleProp; headerPressColorAndroid?: string; headerRight?: React.ReactElement; headerStyle?: StyleProp; + headerForceInset?: HeaderForceInset; headerBackground?: React.ReactNode | React.ReactType; gesturesEnabled?: boolean; gestureResponseDistance?: { vertical?: number; horizontal?: number }; + gestureDirection?: 'default' | 'inverted'; } export interface NavigationStackRouterConfig { @@ -317,7 +365,7 @@ export interface NavigationStackRouterConfig { } export type NavigationStackAction = - NavigationInitAction + | NavigationInitAction | NavigationNavigateAction | NavigationBackAction | NavigationSetParamsAction @@ -326,25 +374,30 @@ export type NavigationStackAction = | NavigationPopToTopAction; export type NavigationTabAction = - NavigationInitAction + | NavigationInitAction | NavigationNavigateAction | NavigationBackAction; export type NavigationAction = - NavigationInitAction + | NavigationInitAction | NavigationStackAction | NavigationTabAction; -export type NavigationRouteConfig = NavigationComponent | ({ - navigationOptions?: NavigationScreenConfig, - path?: string, -} & NavigationScreenRouteConfig); +export type NavigationRouteConfig = + | NavigationComponent + | ({ + navigationOptions?: NavigationScreenConfig; + path?: string; + } & NavigationScreenRouteConfig); -export type NavigationScreenRouteConfig = NavigationComponent | { - screen: NavigationComponent, -} | { - getScreen: () => NavigationComponent, -}; +export type NavigationScreenRouteConfig = + | NavigationComponent + | { + screen: NavigationComponent; + } + | { + getScreen: () => NavigationComponent; + }; export interface NavigationPathsConfig { [routeName: string]: string; @@ -360,45 +413,48 @@ export interface NavigationTabRouterConfig { backBehavior?: 'none' | 'initialRoute'; // defaults `initialRoute` } export interface TabScene { - route: NavigationRoute; - focused: boolean; - index: number; - tintColor?: string; + route: NavigationRoute; + focused: boolean; + index: number; + tintColor?: string; } export interface NavigationTabScreenOptions { title?: string; tabBarIcon?: - React.ReactElement - | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< - any - > | null)); + | React.ReactElement + | (( + options: { tintColor: string | null; focused: boolean } + ) => React.ReactElement | null); tabBarLabel?: - string - | React.ReactElement - | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< - any - > | string | null)); + | string + | React.ReactElement + | (( + options: { tintColor: string | null; focused: boolean } + ) => React.ReactElement | string | null); tabBarVisible?: boolean; - tabBarTestIDProps?: { testID?: string, accessibilityLabel?: string }; - tabBarOnPress?: (options: { - scene: TabScene, - jumpToIndex: (index: number) => void - }) => void; + tabBarTestIDProps?: { testID?: string; accessibilityLabel?: string }; + tabBarOnPress?: ( + options: { + scene: TabScene; + jumpToIndex: (index: number) => void; + } + ) => void; } export interface NavigationDrawerScreenOptions { title?: string; drawerIcon?: - React.ReactElement - | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< - any - > | null)); + | React.ReactElement + | (( + options: { tintColor: string | null; focused: boolean } + ) => React.ReactElement | null); drawerLabel?: - string - | React.ReactElement - | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< - any - > | null)); + | string + | React.ReactElement + | (( + options: { tintColor: string | null; focused: boolean } + ) => React.ReactElement | null); + drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open'; } export interface NavigationRouteConfigMap { @@ -413,22 +469,20 @@ export interface NavigationProp { } export type EventType = -| 'willFocus' -| 'didFocus' -| 'willBlur' -| 'didBlur' -| 'action'; + | 'willFocus' + | 'didFocus' + | 'willBlur' + | 'didBlur' + | 'action'; export interface NavigationEventPayload { type: EventType; action: NavigationAction; state: NavigationState; - lastState: NavigationState; + lastState: NavigationState | null | undefined; } -export type NavigationEventCallback = ( - payload: NavigationEventPayload -) => void; +export type NavigationEventCallback = (payload: NavigationEventPayload) => void; export interface NavigationEventSubscription { remove: () => void; @@ -438,8 +492,14 @@ export interface NavigationScreenProp { state: S; dispatch: NavigationDispatch; goBack: (routeKey?: string | null) => boolean; + dismiss: () => boolean; navigate(options: { - routeName: string; + routeName: string | { + routeName: string; + params?: NavigationParams; + action?: NavigationNavigateAction; + key?: string; + }; params?: NavigationParams; action?: NavigationAction; key?: string; @@ -447,7 +507,7 @@ export interface NavigationScreenProp { navigate( routeNameOrOptions: string, params?: NavigationParams, - action?: NavigationAction, + action?: NavigationAction ): boolean; getParam: (param: T, fallback?: P[T]) => P[T]; setParams: (newParams: P) => boolean; @@ -467,6 +527,7 @@ export interface NavigationScreenProp { ) => boolean; pop: (n?: number, params?: { immediate?: boolean }) => boolean; popToTop: (params?: { immediate?: boolean }) => boolean; + isFocused: () => boolean; } export interface NavigationNavigatorProps { @@ -558,7 +619,7 @@ export type NavigationAnimationSetter = ( lastState: NavigationState ) => void; -export type NavigationSceneRenderer = () => (React.ReactElement | null); +export type NavigationSceneRenderer = () => React.ReactElement | null; export type NavigationStyleInterpolator = ( props: NavigationSceneRendererProps @@ -567,50 +628,49 @@ export type NavigationStyleInterpolator = ( export interface LayoutEvent { nativeEvent: { layout: { - x: number, - y: number, - width: number, - height: number, - }, + x: number; + y: number; + width: number; + height: number; + }; }; } export type NavigatorType = -| 'react-navigation/STACK' -| 'react-navigation/TABS' -| 'react-navigation/DRAWER'; + | 'react-navigation/STACK' + | 'react-navigation/TABS' + | 'react-navigation/DRAWER'; -export function addNavigationHelpers( - navigation: { - state: S; - dispatch: (action: NavigationAction) => any; - addListener?: ( - eventName: string, - callback: NavigationEventCallback - ) => NavigationEventSubscription; - } -): NavigationScreenProp; - -export interface NavigationContainerProps { +export interface NavigationContainerProps { uriPrefix?: string | RegExp; onNavigationStateChange?: ( prevNavigationState: NavigationState, nextNavigationState: NavigationState, - action: NavigationAction, - ) => void; + action: NavigationAction + ) => void | null | undefined; + navigation?: NavigationScreenProp; + persistenceKey?: string | null | undefined; + renderLoadingExperimental?: React.ComponentType<{}>, + screenProps?: any; + navigationOptions?: O; style?: StyleProp; } -export interface NavigationContainerComponent extends React.Component< +export interface NavigationContainerComponent + extends React.Component< NavigationContainerProps & NavigationNavigatorProps > { dispatch: NavigationDispatch; } -export interface NavigationContainer extends React.ComponentClass< +export interface NavigationContainer + extends React.ComponentClass< NavigationContainerProps & NavigationNavigatorProps > { - new(props: NavigationContainerProps & NavigationNavigatorProps, context?: any): NavigationContainerComponent; + new( + props: NavigationContainerProps & NavigationNavigatorProps, + context?: any + ): NavigationContainerComponent; router: NavigationRouter; screenProps: { [key: string]: any }; @@ -618,29 +678,43 @@ export interface NavigationContainer extends React.ComponentClass< state: { nav: NavigationState | null }; } -export interface StackNavigatorConfig extends NavigationStackViewConfig, NavigationStackRouterConfig { +export interface StackNavigatorConfig + extends NavigationStackViewConfig, + NavigationStackRouterConfig { containerOptions?: any; } // Return createNavigationContainer export function StackNavigator( routeConfigMap: NavigationRouteConfigMap, - stackConfig?: StackNavigatorConfig, + stackConfig?: StackNavigatorConfig +): NavigationContainer; + +export function createStackNavigator( + routeConfigMap: NavigationRouteConfigMap, + stackConfig?: StackNavigatorConfig ): NavigationContainer; export interface SwitchNavigatorConfig { initialRouteName: string; resetOnBlur?: boolean; paths?: NavigationPathsConfig; - backBehavior?: 'none' | 'initialRoute'; + backBehavior?: 'none' | 'intialRoute'; } // Return createNavigationContainer +export type _SwitchNavigatorConfig = NavigationSwitchRouterConfig; + export function SwitchNavigator( routeConfigMap: NavigationRouteConfigMap, switchConfig?: SwitchNavigatorConfig ): NavigationContainer; +export function createSwitchNavigator( + routeConfigMap: NavigationRouteConfigMap, + switchConfig?: SwitchNavigatorConfig +): NavigationContainer; + // DrawerItems export const DrawerItems: React.ReactType; @@ -655,21 +729,28 @@ export interface DrawerViewConfig { contentOptions?: any; style?: StyleProp; } -export interface DrawerNavigatorConfig extends NavigationTabRouterConfig, DrawerViewConfig { +export interface DrawerNavigatorConfig + extends NavigationTabRouterConfig, + DrawerViewConfig { containerConfig?: any; contentOptions?: { - activeTintColor?: string, - activeBackgroundColor?: string, - inactiveTintColor?: string, - inactiveBackgroundColor?: string, - style?: StyleProp, - labelStyle?: StyleProp, + activeTintColor?: string; + activeBackgroundColor?: string; + inactiveTintColor?: string; + inactiveBackgroundColor?: string; + style?: StyleProp; + labelStyle?: StyleProp; }; } export function DrawerNavigator( routeConfigMap: NavigationRouteConfigMap, - drawerConfig?: DrawerNavigatorConfig, + drawerConfig?: DrawerNavigatorConfig +): NavigationContainer; + +export function createDrawerNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawerConfig?: DrawerNavigatorConfig ): NavigationContainer; /** @@ -681,23 +762,23 @@ export interface TabViewConfig { tabBarComponent?: React.ReactType; tabBarPosition?: 'top' | 'bottom'; tabBarOptions?: { - activeTintColor?: string, - allowFontScaling?: boolean, - activeBackgroundColor?: string, - inactiveTintColor?: string, - inactiveBackgroundColor?: string, - showLabel?: boolean, - style?: StyleProp, - labelStyle?: StyleProp, - iconStyle?: StyleProp, + activeTintColor?: string; + allowFontScaling?: boolean; + activeBackgroundColor?: string; + inactiveTintColor?: string; + inactiveBackgroundColor?: string; + showLabel?: boolean; + style?: StyleProp; + labelStyle?: StyleProp; + iconStyle?: StyleProp; // Top - showIcon?: boolean, - upperCaseLabel?: boolean, - pressColor?: string, - pressOpacity?: number, - scrollEnabled?: boolean, - tabStyle?: StyleProp, - indicatorStyle?: StyleProp, + showIcon?: boolean; + upperCaseLabel?: boolean; + pressColor?: string; + pressOpacity?: number; + scrollEnabled?: boolean; + tabStyle?: StyleProp; + indicatorStyle?: StyleProp; }; swipeEnabled?: boolean; animationEnabled?: boolean; @@ -705,16 +786,33 @@ export interface TabViewConfig { } // From navigators/TabNavigator.js -export interface TabNavigatorConfig extends NavigationTabRouterConfig, TabViewConfig { +export interface TabNavigatorConfig + extends NavigationTabRouterConfig, + TabViewConfig { lazy?: boolean; removeClippedSubviews?: boolean; - initialLayout?: { height: number, width: number }; + initialLayout?: { height: number; width: number }; } // From navigators/TabNavigator.js export function TabNavigator( routeConfigMap: NavigationRouteConfigMap, - drawConfig?: TabNavigatorConfig, + drawConfig?: TabNavigatorConfig +): NavigationContainer; + +export function createTabNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawConfig?: TabNavigatorConfig +): NavigationContainer; + +export function createBottomTabNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawConfig?: TabNavigatorConfig +): NavigationContainer; + +export function createMaterialTopNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawConfig?: TabNavigatorConfig ): NavigationContainer; export interface TabBarTopProps { @@ -729,15 +827,17 @@ export interface TabBarTopProps { tabBarPosition: string; navigation: NavigationScreenProp; jumpToIndex: (index: number) => void; - getLabel: (scene: TabScene) => (React.ReactNode | string); + getLabel: (scene: TabScene) => React.ReactNode | string; getOnPress: ( previousScene: NavigationRoute, scene: TabScene - ) => (args: { - previousScene: NavigationRoute, - scene: TabScene, - jumpToIndex: (index: number) => void, - }) => void; + ) => ( + args: { + previousScene: NavigationRoute; + scene: TabScene; + jumpToIndex: (index: number) => void; + } + ) => void; renderIcon: (scene: TabScene) => React.ReactElement; labelStyle?: TextStyle; iconStyle?: ViewStyle; @@ -754,15 +854,17 @@ export interface TabBarBottomProps { position: AnimatedValue; navigation: NavigationScreenProp; jumpToIndex: (index: number) => void; - getLabel: (scene: TabScene) => (React.ReactNode | string); + getLabel: (scene: TabScene) => React.ReactNode | string; getOnPress: ( previousScene: NavigationRoute, scene: TabScene - ) => (args: { - previousScene: NavigationRoute, - scene: TabScene, - jumpToIndex: (index: number) => void, - }) => void; + ) => ( + args: { + previousScene: NavigationRoute; + scene: TabScene; + jumpToIndex: (index: number) => void; + } + ) => void; getTestIDProps: (scene: TabScene) => (scene: TabScene) => any; renderIcon: (scene: TabScene) => React.ReactNode; style?: ViewStyle; @@ -789,12 +891,18 @@ export namespace NavigationActions { const POP_TO_TOP: 'Navigation/POP_TO_TOP'; function init(options?: NavigationInitActionPayload): NavigationInitAction; - function navigate(options: NavigationNavigateActionPayload): NavigationNavigateAction; + function navigate( + options: NavigationNavigateActionPayload + ): NavigationNavigateAction; function reset(options: NavigationResetActionPayload): NavigationResetAction; function back(options?: NavigationBackActionPayload): NavigationBackAction; - function setParams(options: NavigationSetParamsActionPayload): NavigationSetParamsAction; + function setParams( + options: NavigationSetParamsActionPayload + ): NavigationSetParamsAction; function pop(options: NavigationPopActionPayload): NavigationPopAction; - function popToTop(options: NavigationPopToTopActionPayload): NavigationPopToTopAction; + function popToTop( + options: NavigationPopToTopActionPayload + ): NavigationPopToTopAction; } /** @@ -807,8 +915,14 @@ export interface TransitionerProps { prevTransitionProps?: NavigationTransitionProps ) => NavigationTransitionSpec; navigation: NavigationScreenProp; - onTransitionStart?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => Promise | void; - onTransitionEnd?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => void; + onTransitionStart?: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps?: NavigationTransitionProps + ) => Promise | void; + onTransitionEnd?: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps?: NavigationTransitionProps + ) => void; render: ( transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps @@ -826,7 +940,7 @@ export interface TransitionerState { export class Transitioner extends React.Component< TransitionerProps, TransitionerState -> { } + > { } /** * Tab Router @@ -853,12 +967,23 @@ export function StackRouter( * * @see https://github.com/react-navigation/react-navigation/blob/master/src/navigators/createNavigator.js */ +export interface NavigationDescriptor { + key: string; + state: NavigationLeafRoute | NavigationStateRoute; + navigation: NavigationScreenProp; + getComponent: () => React.ComponentType<{}>; +} + +export type NavigationView = React.ComponentType<{ + descriptors: { [key: string]: NavigationDescriptor }; +} & NavigationInjectedProps>; + export function createNavigator( + view: NavigationView, router: NavigationRouter, - routeConfigs?: NavigationRouteConfigMap, navigatorConfig?: {} | null, navigatorType?: NavigatorType -): (NavigationView: React.ComponentClass) => NavigationNavigator; +): any; /** * Create an HOC that injects the navigation and manages the navigation state @@ -879,7 +1004,10 @@ export function createNavigationContainer( * BEGIN CUSTOM CONVENIENCE INTERFACES */ -export interface NavigationScreenProps { +export interface NavigationScreenProps< + Params = NavigationParams, + Options = any + > { navigation: NavigationScreenProp, Params>; screenProps?: { [key: string]: any }; navigationOptions?: NavigationScreenConfig; @@ -936,6 +1064,7 @@ export interface SafeAreaViewProps extends ViewProps { horizontal?: SafeAreaViewForceInsetValue; vertical?: SafeAreaViewForceInsetValue; }; + children?: React.ReactNode; } export const SafeAreaView: React.ComponentClass; From 9f18f414ecb2666e0e810da8e6f6220c3d09aedc Mon Sep 17 00:00:00 2001 From: forest yox Date: Thu, 17 May 2018 13:52:26 -0400 Subject: [PATCH 019/236] added acoords --- types/fabric/fabric-impl.d.ts | 5 +++++ types/fabric/test/index.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index e35b0ebe0d..580b132e60 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -2249,6 +2249,11 @@ interface IObjectOptions { * Not used by fabric, just for convenience */ data?: any; + + /** + * Describes the object's corner position in canvas object absolute properties. + */ + aCoords?: {bl: Point, br: Point, tl: Point, tr: Point}; } export interface Object extends IObservable, IObjectOptions, IObjectAnimation { } export class Object { diff --git a/types/fabric/test/index.ts b/types/fabric/test/index.ts index 1060525a00..e6b72b4281 100644 --- a/types/fabric/test/index.ts +++ b/types/fabric/test/index.ts @@ -1,3 +1,4 @@ + function sample1() { const canvas = new fabric.Canvas('c', { hoverCursor: 'pointer', From 80ad40ad7817831d5daaa54edac229a666278990 Mon Sep 17 00:00:00 2001 From: forest yox Date: Thu, 17 May 2018 14:34:29 -0400 Subject: [PATCH 020/236] fixed inadvertant whitespace --- types/fabric/test/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/fabric/test/index.ts b/types/fabric/test/index.ts index e6b72b4281..1060525a00 100644 --- a/types/fabric/test/index.ts +++ b/types/fabric/test/index.ts @@ -1,4 +1,3 @@ - function sample1() { const canvas = new fabric.Canvas('c', { hoverCursor: 'pointer', From 96a4cebfb03d9e561eface2717ba591a0c3f0572 Mon Sep 17 00:00:00 2001 From: Simon Epskamp Date: Thu, 17 May 2018 23:04:27 +0200 Subject: [PATCH 021/236] react-transition-group: allow component={null} on TransitionGroup --- types/react-transition-group/TransitionGroup.d.ts | 2 +- types/react-transition-group/index.d.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/react-transition-group/TransitionGroup.d.ts b/types/react-transition-group/TransitionGroup.d.ts index 13e8daf228..913c034729 100644 --- a/types/react-transition-group/TransitionGroup.d.ts +++ b/types/react-transition-group/TransitionGroup.d.ts @@ -3,7 +3,7 @@ import { TransitionActions, TransitionProps } from "./Transition"; declare namespace TransitionGroup { interface IntrinsicTransitionGroupProps extends TransitionActions { - component?: T; + component?: T|null; } interface ComponentTransitionGroupProps extends TransitionActions { diff --git a/types/react-transition-group/index.d.ts b/types/react-transition-group/index.d.ts index 6a90201af5..dbe906f679 100644 --- a/types/react-transition-group/index.d.ts +++ b/types/react-transition-group/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for react-transition-group 2.0 // Project: https://github.com/reactjs/react-transition-group // Definitions by: Karol Janyst +// Epskampie // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 From 57cb3558e2bedbdd1f0e0030ec33f860795d9755 Mon Sep 17 00:00:00 2001 From: waterfoul Date: Fri, 18 May 2018 08:56:09 -0500 Subject: [PATCH 022/236] Fixed the typings for inferred types with functional components --- types/react-redux/index.d.ts | 13 ++++--- types/react-redux/react-redux-tests.tsx | 51 +++++++++++++++++-------- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index 0519a43bb5..a7f3dea705 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-redux 6.0.0 +// Type definitions for react-redux 6.0.1 // Project: https://github.com/rackt/react-redux // Definitions by: Qubo , // Thomas Hasner , @@ -54,7 +54,7 @@ interface AdvancedComponentDecorator { * - it is present in both DecorationTargetProps and InjectedProps * - DecorationTargetProps[P] extends InjectedProps[P] * ie: decorated component can accept more types than decorator is injecting - * + * * For decoration, inject props or ownProps are all optionnaly * required by the decorated (right hand side) component. * But any property required by the decorated component must extend the injected property @@ -70,9 +70,12 @@ type Shared< // Will not pass through the injected props if they are passed in during // render. Also adds new prop requirements from TNeedsProps. export interface InferableComponentEnhancerWithProps { -

>( - component: Component

- ): ComponentClass> & TNeedsProps> & {WrappedComponent: Component

} + ( + component: StatelessComponent + ): ComponentClass & {WrappedComponent: StatelessComponent} +

>( + component: Component

+ ): ComponentClass> & TNeedsProps> & {WrappedComponent: Component

} } // Injects props and removes them from the prop requirements. diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index ebc174dd1c..16fb7f0306 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -813,23 +813,42 @@ namespace TestControlledComponentWithoutDispatchProp { } namespace TestDispatchToPropsAsObject { - const onClick: ActionCreator<{}> = () => ({}); - const mapStateToProps = (state: any) => { - return { - title: state.app.title as string, - }; - }; - const dispatchToProps = { - onClick, - }; + const onClick: ActionCreator<{}> = () => ({}); + const mapStateToProps = (state: any) => { + return { + title: state.app.title as string, + }; + }; + const dispatchToProps = { + onClick, + }; - type Props = { title: string; } & typeof dispatchToProps; - const HeaderComponent: React.StatelessComponent = (props) => { - return

{props.title}

; - } + type Props = { title: string; } & typeof dispatchToProps; + const HeaderComponent: React.StatelessComponent = (props) => { + return

{props.title}

; + } - const Header = connect(mapStateToProps, dispatchToProps)(HeaderComponent); -
+ const Header = connect(mapStateToProps, dispatchToProps)(HeaderComponent); +
+} + +namespace TestInferredFunctionalComponent { + + const Header = connect( + ( + { app: { title }}: { app: { title: string }}, + { extraText }: { extraText: string } + ) => ({ + title, + extraText + }), + (dispatch) => ({ + onClick: () => dispatch({ type: 'test' }) + }) + )(({ title, extraText, onClick }) => { + return

{title} {extraText}

; + }); +
} namespace TestWrappedComponent { @@ -933,7 +952,7 @@ namespace TestWithoutTOwnPropsDecoratedInference { // This should compile React.createElement(ConnectedWithOwnPropsClass, { own: 'string', forwarded: 'string' }); React.createElement(ConnectedWithOwnPropsClass, { own: 'string', forwarded: 'string' }); - + // This should not compile, it is missing ForwardedProps React.createElement(ConnectedWithOwnPropsClass, { own: 'string' }); // $ExpectError React.createElement(ConnectedWithOwnPropsStateless, { own: 'string' }); // $ExpectError From 88dcf587649c88e8734b33ce16e528fd5a9cd288 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 18 May 2018 14:16:57 -0700 Subject: [PATCH 023/236] Remove dependency on types not in ES5 --- types/node/index.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 9a9fc544e2..cdf49f39e1 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -6205,25 +6205,25 @@ declare module "util" { export function isInt8Array(object: any): object is Int8Array; export function isInt16Array(object: any): object is Int16Array; export function isInt32Array(object: any): object is Int32Array; - export function isMap(object: any): object is Map; + export function isMap(object: any): boolean; export function isMapIterator(object: any): boolean; export function isNativeError(object: any): object is Error; export function isNumberObject(object: any): object is Number; - export function isPromise(object: any): object is Promise; + export function isPromise(object: any): boolean; export function isProxy(object: any): boolean; export function isRegExp(object: any): object is RegExp; - export function isSet(object: any): object is Set; + export function isSet(object: any): boolean; export function isSetIterator(object: any): boolean; export function isSharedArrayBuffer(object: any): boolean; - export function isStringObject(object: any): object is String; - export function isSymbolObject(object: any): object is Symbol; + export function isStringObject(object: any): boolean; + export function isSymbolObject(object: any): boolean; export function isTypedArray(object: any): object is Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array; export function isUint8Array(object: any): object is Uint8Array; export function isUint8ClampedArray(object: any): object is Uint8ClampedArray; export function isUint16Array(object: any): object is Uint16Array; export function isUint32Array(object: any): object is Uint32Array; - export function isWeakMap(object: any): object is WeakMap; - export function isWeakSet(object: any): object is WeakSet; + export function isWeakMap(object: any): boolean; + export function isWeakSet(object: any): boolean; export function isWebAssemblyCompiledModule(object: any): boolean; } From ee04278cb856cc5ca1f906ff6f0713d6bf24b838 Mon Sep 17 00:00:00 2001 From: Dmitrii Sorin Date: Sun, 20 May 2018 10:22:33 +1000 Subject: [PATCH 024/236] Add multiple forgotten mocha API methods --- types/mocha/index.d.ts | 293 ++++++++++++++++++++++++++++++------- types/mocha/mocha-tests.ts | 34 +++-- 2 files changed, 259 insertions(+), 68 deletions(-) diff --git a/types/mocha/index.d.ts b/types/mocha/index.d.ts index 0e066791eb..2dd6bb2c21 100644 --- a/types/mocha/index.d.ts +++ b/types/mocha/index.d.ts @@ -5,10 +5,28 @@ // jt000 // Vadim Macagon // Andrew Bradley +// Dmitrii Sorin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 -interface MochaSetupOptions { +/** + * Mocha is using node.js EventEmitter for its internal classes + * But when it's executed in the browser environment it bundles a 3rd party EventEmitter in its code + * Also node.js EventEmitter brings its globals which cannot be used in the browser environment. + * So it's unsafe to reference node EventEmitter here, that's why we have a generic interface for EventEmitter. + * + * @see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/25117#issuecomment-383404187 + */ +declare class GenericEventEmitter { + addListener(event: string, listener: (...args: any[]) => void): GenericEventEmitter; + on(event: string, listener: (...args: any[]) => void): GenericEventEmitter; + once(event: string, listener: (...args: any[]) => void): GenericEventEmitter; + removeListener(event: string, listener: (...args: any[]) => void): GenericEventEmitter; + removeAllListeners(event?: string): GenericEventEmitter; + emit(event: string, ...args: any[]): boolean; + } + + interface MochaSetupOptions { // milliseconds to wait before considering a test slow slow?: number; @@ -35,61 +53,67 @@ interface MochaSetupOptions { // require modules before running tests require?: string[]; -} -declare const mocha: Mocha; -declare const describe: Mocha.IContextDefinition; -declare const xdescribe: Mocha.IContextDefinition; -// alias for `describe` -declare const context: Mocha.IContextDefinition; -// alias for `describe` -declare const suite: Mocha.IContextDefinition; -declare const it: Mocha.ITestDefinition; -declare const xit: Mocha.ITestDefinition; -// alias for `it` -declare const test: Mocha.ITestDefinition; -declare const specify: Mocha.ITestDefinition; + asyncOnly?: boolean; + delay?: boolean; + files?: string[]; + forbidOnly?: boolean; + forbidPending?: boolean; + fullStackTrace?: boolean; + hasOnly?: boolean; + } -// Used with the --delay flag; see https://mochajs.org/#hooks -declare function run(): void; + declare const mocha: Mocha; + declare const describe: Mocha.IContextDefinition; + declare const xdescribe: Mocha.IContextDefinition; + // alias for `describe` + declare const context: Mocha.IContextDefinition; + // alias for `describe` + declare const suite: Mocha.IContextDefinition; + declare const it: Mocha.ITestDefinition; + declare const xit: Mocha.ITestDefinition; + // alias for `it` + declare const test: Mocha.ITestDefinition; + declare const specify: Mocha.ITestDefinition; -type MochaDone = (error?: any) => void; + // Used with the --delay flag; see https://mochajs.org/#hooks + declare function run(): void; -declare function setup(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; -declare function teardown(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; -declare function suiteSetup(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; -declare function suiteTeardown(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; -declare function before(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; -declare function before(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; -declare function after(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; -declare function after(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; -declare function beforeEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; -declare function beforeEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; -declare function afterEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; -declare function afterEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; + type MochaDone = (error?: any) => void; -interface ReporterConstructor { + declare function setup(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; + declare function teardown(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; + declare function suiteSetup(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; + declare function suiteTeardown(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; + declare function before(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; + declare function before(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; + declare function after(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; + declare function after(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => PromiseLike | void): void; + declare function beforeEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; + declare function beforeEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; + declare function afterEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; + declare function afterEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; + + interface ReporterConstructor { new(runner: Mocha.IRunner, options: any): any; -} + } -declare class Mocha { + declare class Mocha { currentTest: Mocha.ITestDefinition; suite: Mocha.ISuite; + files: string[]; + options: MochaSetupOptions; - constructor(options?: { - grep?: RegExp; - ui?: string; - reporter?: string | ReporterConstructor; - timeout?: number; - reporterOptions?: any; - slow?: number; - bail?: boolean; - }); + constructor(options?: MochaSetupOptions); + asyncOnly(): Mocha; + asyncOnly(value: boolean): Mocha; + delay(): Mocha; + forbidOnly(): Mocha; + forbidPending(): Mocha; + fullTrace(): Mocha; /** Setup mocha with the given interface. */ setup(interface: Mocha.Interface): Mocha; - /** Setup mocha with the given options. */ - setup(options: MochaSetupOptions): Mocha; bail(value?: boolean): Mocha; addFile(file: string): Mocha; /** Sets reporter by name, defaults to "spec". */ @@ -117,15 +141,22 @@ declare class Mocha { timeout(value: number): Mocha; slow(value: number): Mocha; enableTimeouts(value: boolean): Mocha; - asyncOnly(value: boolean): Mocha; noHighlighting(value: boolean): Mocha; /** Runs tests and invokes `onComplete()` when finished. */ run(onComplete?: (failures: number) => void): Mocha.IRunner; loadFiles(cb?: () => any): void; -} -// merge the Mocha class declaration with a module -declare namespace Mocha { + // internals exposed via exports.* + Runnable: Mocha.Runnable; + Context: Mocha.Context; + Runner: Mocha.Runner; + Suite: Mocha.Suite; + Hook: Mocha.Hook; + Test: Mocha.Test; + } + + // merge the Mocha class declaration with a module + declare namespace Mocha { /** Third-party declarations that want to add new interfaces can contribute names here */ interface InterfaceContributions { bdd: any; @@ -136,6 +167,22 @@ declare namespace Mocha { type Interface = keyof InterfaceContributions; + interface IContext { + _runnable?: IRunnable; + test?: IRunnable; + + runnable(): IRunnable | undefined; + runnable(runnable: IRunnable): IContext; + timeout(): number; + timeout(timeout: number): IContext; + enableTimeouts(enableTimeouts: boolean): IContext; + slow(slow: number): IContext; + skip(): IContext; + retries(): number; + retries(retries: number): IContext; + inspect(): string; + } + interface ISuiteCallbackContext { timeout(ms: number | string): this; retries(n: number): this; @@ -157,7 +204,7 @@ declare namespace Mocha { } /** Partial interface for Mocha's `Runnable` class. */ - interface IRunnable { + interface IRunnable extends GenericEventEmitter { title: string; fn: Function; async: boolean; @@ -169,22 +216,49 @@ declare namespace Mocha { /** Partial interface for Mocha's `Suite` class. */ interface ISuite { + ctx: IContext; parent: ISuite; + root: boolean; title: string; suites: ISuite[]; + tests: ITest[]; + _beforeEach: IHook[]; + _beforeAll: IHook[]; + _afterEach: IHook[]; + _afterAll: IHook[]; + + bail(): boolean; + bail(bail: boolean): ISuite; fullTitle(): string; + retries(): number; + retries(retries: number): ISuite; + slow(): number; + slow(slow: number): ISuite; + timeout(): number; + timeout(timeout: number): ISuite; } /** Partial interface for Mocha's `Test` class. */ interface ITest extends IRunnable { + body?: string; + file?: string; parent: ISuite; pending: boolean; state: 'failed' | 'passed' | undefined; + type: 'test'; fullTitle(): string; } + interface IHook extends IRunnable { + ctx?: IContext; + parent?: ISuite; + type: 'hook'; + + error(err: Error): void; + } + interface IBeforeAndAfterContext extends IHookCallbackContext { currentTest: ITest; } @@ -201,12 +275,19 @@ declare namespace Mocha { } /** Partial interface for Mocha's `Runner` class. */ - interface IRunner { + interface IRunner extends GenericEventEmitter { + asyncOnly?: boolean; stats?: IStats; started: boolean; suite: ISuite; total: number; failures: number; + forbidOnly?: boolean; + forbidPending?: boolean; + fullStackTrace?: boolean; + hasOnly?: boolean; + ignoreLeaks?: boolean; + grep: (re: string, invert: boolean) => this; grepTotal: (suite: ISuite) => number; globals: (arr: ReadonlyArray) => this | string[]; @@ -231,6 +312,7 @@ declare namespace Mocha { namespace reporters { class Base { + runner: IRunner; stats: IStats; constructor(runner: IRunner); @@ -326,8 +408,115 @@ declare namespace Mocha { function afterEach(callback: (this: IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; /** Only available when invoked via the mocha CLI */ function afterEach(description: string, callback: (this: IBeforeAndAfterContext, done: MochaDone) => PromiseLike | void): void; -} -declare module "mocha" { + class Runnable extends GenericEventEmitter { + new(title: string, fn: () => any): IRunnable; + } + + class Context implements IContext { + constructor(); + + _runnable?: IRunnable; + test?: IRunnable; + + runnable(): IRunnable | undefined; + runnable(runnable: IRunnable): IContext; + timeout(): number; + timeout(timeout: number): IContext; + enableTimeouts(enableTimeouts: boolean): IContext; + slow(slow: number): IContext; + skip(): IContext; + retries(): number; + retries(retries: number): IContext; + inspect(): string; + } + + class Runner extends GenericEventEmitter implements IRunner { + constructor(suite: ISuite, delay: boolean); + + asyncOnly?: boolean; + stats?: IStats; + started: boolean; + suite: ISuite; + total: number; + failures: number; + forbidOnly?: boolean; + forbidPending?: boolean; + fullStackTrace?: boolean; + hasOnly?: boolean; + ignoreLeaks?: boolean; + + grep: (re: string, invert: boolean) => this; + grepTotal: (suite: ISuite) => number; + globals: (arr: ReadonlyArray) => this | string[]; + abort: () => this; + run: (fn?: (failures: number) => void) => this; + } + + class Suite extends GenericEventEmitter implements ISuite { + constructor(title: string, parentContext: IContext); + + ctx: IContext; + parent: ISuite; + root: boolean; + title: string; + suites: ISuite[]; + tests: ITest[]; + + _beforeEach: IHook[]; + _beforeAll: IHook[]; + _afterEach: IHook[]; + _afterAll: IHook[]; + + bail(): boolean; + bail(bail: boolean): ISuite; + fullTitle(): string; + retries(): number; + retries(retries: number): ISuite; + slow(): number; + slow(slow: number): ISuite; + timeout(): number; + timeout(timeout: number): ISuite; + } + + class Hook extends Runnable implements IHook { + constructor(title: string, fn: () => any); + + async: boolean; + ctx?: IContext; + duration?: number; + fn: Function; + parent?: ISuite; + sync: boolean; + timedOut: boolean; + timeout(n: number | string): this; + title: string; + type: 'hook'; + + error(err: Error): void; + } + + class Test extends Runnable implements ITest { + constructor(title: string, fn: () => any); + + async: boolean; + body?: string; + duration?: number; + file?: string; + fn: Function; + parent: ISuite; + pending: boolean; + state: 'failed' | 'passed' | undefined; + sync: boolean; + timedOut: boolean; + timeout(n: number | string): this; + title: string; + type: 'test'; + + fullTitle(): string; + } + } + + declare module "mocha" { export = Mocha; -} + } diff --git a/types/mocha/mocha-tests.ts b/types/mocha/mocha-tests.ts index f2fa323f19..ec9b238d80 100644 --- a/types/mocha/mocha-tests.ts +++ b/types/mocha/mocha-tests.ts @@ -7,9 +7,12 @@ import { describe as importedDescribe, it as importedIt, xdescribe as importedXdescribe, - xit as importedXit + xit as importedXit, } from 'mocha'; +// tslint:disable-next-line +import * as Mocha from 'mocha'; + // Warning!! // Don't refer node.d.ts!! // See #22510. @@ -454,55 +457,55 @@ function test_reporter_function() { } function test_setup_slow_option() { - mocha.setup({ slow: 25 }); + new Mocha({ slow: 25 }); } function test_setup_timeout_option() { - mocha.setup({ timeout: 25 }); + new Mocha({ timeout: 25 }); } function test_setup_globals_option() { - mocha.setup({ globals: ['mocha'] }); + new Mocha({ globals: ['mocha'] }); } function test_setup_ui_option() { - mocha.setup({ ui: 'bdd' }); + new Mocha({ ui: 'bdd' }); } function test_setup_reporter_string_option() { - mocha.setup({ reporter: 'html' }); + new Mocha({ reporter: 'html' }); } function test_setup_require_stringArray_option() { - mocha.setup({ require: ['ts-node/register'] }); + new Mocha({ require: ['ts-node/register'] }); } function test_setup_reporter_function_option() { - mocha.setup({ reporter: class { } }); + new Mocha({ reporter: class { } }); } function test_setup_bail_option() { - mocha.setup({ bail: false }); + new Mocha({ bail: false }); } function test_setup_ignore_leaks_option() { - mocha.setup({ ignoreLeaks: false }); + new Mocha({ ignoreLeaks: false }); } function test_setup_grep_string_option() { - mocha.setup({ grep: "describe" }); + new Mocha({ grep: "describe" }); } function test_setup_grep_regex_option() { - mocha.setup({ grep: new RegExp('describe') }); + new Mocha({ grep: new RegExp('describe') }); } function test_setup_grep_regex_literal_option() { - mocha.setup({ grep: /(expect|should)/i }); + new Mocha({ grep: /(expect|should)/i }); } function test_setup_all_options() { - mocha.setup({ + new Mocha({ slow: 25, timeout: 25, ui: 'bdd', @@ -524,8 +527,7 @@ function test_growl() { } function test_chaining() { - mocha - .setup({ slow: 25 }) + new Mocha({ slow: 25 }) .growl() .reporter('html') .reporter(class { }); From 617a2a8ad8135f39b3e917822a9cd07498976599 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 21 May 2018 11:31:56 +0200 Subject: [PATCH 025/236] d3-color : added piecewise method #25582 --- types/d3-interpolate/d3-interpolate-tests.ts | 13 +++++++++++++ types/d3-interpolate/index.d.ts | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/types/d3-interpolate/d3-interpolate-tests.ts b/types/d3-interpolate/d3-interpolate-tests.ts index 6baaf06092..50ade8008c 100644 --- a/types/d3-interpolate/d3-interpolate-tests.ts +++ b/types/d3-interpolate/d3-interpolate-tests.ts @@ -229,3 +229,16 @@ iString = d3Interpolate.interpolateCubehelixLong.gamma(2.2)('purple', 'orange'); iNum = d3Interpolate.interpolateBasis([1, 50, 30, 10]); iNum = d3Interpolate.interpolateBasisClosed([1, 50, 30, 10]); + +iString = d3Interpolate.piecewise(d3Interpolate.interpolateRgb.gamma(2.2), ['red', 'green', 'blue']); +iString = d3Interpolate.piecewise(d3Interpolate.interpolateCubehelix, ['red', 'green', 'blue']); +iZoom = d3Interpolate.piecewise(d3Interpolate.interpolateZoom, [[50, 50, 300], [100, 100, 500]] as d3Interpolate.ZoomView[]); +iNum = d3Interpolate.piecewise(d3Interpolate.interpolateNumber, [1, 2, 3]); +iNum = d3Interpolate.piecewise(d3Interpolate.interpolateRound, [1.1, 2.2, 3.3]); +iString = d3Interpolate.piecewise(d3Interpolate.interpolateString, ['a', 'b', 'c']); +iDate = d3Interpolate.piecewise(d3Interpolate.interpolateDate, [new Date(2018, 5, 1), new Date(2018, 5, 2), new Date(2018, 5, 3)]); +iArrayNum = d3Interpolate.piecewise(d3Interpolate.interpolateArray, [1, 2, 4, 8]); +iArrayStr = d3Interpolate.piecewise(d3Interpolate.interpolateArray, ['a', 'b', 'c', 'd']); +iArrayMixed = d3Interpolate.piecewise<[Date, string]>(d3Interpolate.interpolateArray, [new Date(2016, 6, 1), 'b: 1']); +iString = d3Interpolate.piecewise(d3Interpolate.interpolateTransformCss, ['rotate(0deg)', 'rotate(60deg)']); +iString = d3Interpolate.piecewise(d3Interpolate.interpolateTransformSvg, ['rotate(0)', 'rotate(60)']); diff --git a/types/d3-interpolate/index.d.ts b/types/d3-interpolate/index.d.ts index e3fcfa21d8..4d6d67f5d5 100644 --- a/types/d3-interpolate/index.d.ts +++ b/types/d3-interpolate/index.d.ts @@ -55,7 +55,9 @@ export function interpolateString(a: string | { toString(): string }, b: string export function interpolateDate(a: Date, b: Date): ((t: number) => Date); -export function interpolateArray(a: any[], b: A): ((t: number) => A); +type ArrayInterpolator = ((t: number) => A); + +export function interpolateArray(a: any[], b: A): ArrayInterpolator; export function interpolateObject(a: any, b: U): ((t: number) => U); // TODO: extends 'any' should become 'object' with TS 2.2+ definitions export function interpolateObject(a: { [key: string]: any }, b: { [key: string]: any }): ((t: number) => { [key: string]: any }); @@ -89,3 +91,7 @@ export const interpolateCubehelixLong: ColorGammaInterpolationFactory; export function interpolateBasis(splineNodes: number[]): ((t: number) => number); export function interpolateBasisClosed(splineNodes: number[]): ((t: number) => number); + +export function piecewise(interpolate: (a: ZoomView, b: ZoomView) => ZoomInterpolator, values: ZoomView[]): ZoomInterpolator; +export function piecewise(interpolate: (a: any[], b: A) => ArrayInterpolator, values: A): ArrayInterpolator; +export function piecewise(interpolate: (a: TData, b: TData) => Interpolator, values: TData[]): (t: number) => any; From bc24e50bc1d814d64f05880583cf515b03ca7086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Magrin?= Date: Mon, 21 May 2018 11:53:22 +0200 Subject: [PATCH 026/236] Change type definition for v2 --- types/react-navigation/index.d.ts | 477 +++----- types/react-navigation/v2/index.d.ts | 1086 +++++++++++++++++ .../v2/react-navigation-tests.tsx | 453 +++++++ types/react-navigation/v2/tsconfig.json | 30 + types/react-navigation/v2/tslint.json | 1 + 5 files changed, 1744 insertions(+), 303 deletions(-) create mode 100644 types/react-navigation/v2/index.d.ts create mode 100644 types/react-navigation/v2/react-navigation-tests.tsx create mode 100644 types/react-navigation/v2/tsconfig.json create mode 100644 types/react-navigation/v2/tslint.json diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 641dd8463f..1233ca39e3 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-navigation 2.0.1 +// Type definitions for react-navigation 1.5 // Project: https://github.com/react-navigation/react-navigation // Definitions by: Huhuanming // mhcgrq @@ -16,12 +16,11 @@ // Armando Assuncao // Ciaran Liedeman // Edward Sammut Alessi -// Jeremy Magrin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 /** - * Reference: https://github.com/react-navigation/react-navigation/tree/a37473c5e4833f48796ee6c7c9cb4a8ac49d9c06 + * Reference: https://github.com/react-navigation/react-navigation/tree/3f3ef6485c8932f49fddc3dd2c508629110bf2b6 * * NOTE: Please update the commit/link above when updating to a new Flow * react-navigation/flow/react-navigation.js reference, so we can conveniently just look at diffs on @@ -44,21 +43,15 @@ export type AnimatedValue = any; export type HeaderMode = 'float' | 'screen' | 'none'; -export interface HeaderForceInset { - horizontal?: string; - vertical?: string, - left?: string, - right?: string, - top?: string, - bottom?: string, -} - export interface HeaderProps extends NavigationSceneRendererProps { mode: HeaderMode; - router: NavigationRouter; - getScreenDetails: ( - navigationScene: NavigationScene - ) => NavigationScreenDetails; + router: NavigationRouter< + NavigationState, + NavigationStackScreenOptions + >; + getScreenDetails: (navigationScene: NavigationScene) => NavigationScreenDetails< + NavigationStackScreenOptions + >; style: StyleProp; } @@ -83,9 +76,7 @@ export interface NavigationState { routes: any[]; } -export type NavigationRoute = - | NavigationLeafRoute - | NavigationStateRoute; +export type NavigationRoute = NavigationLeafRoute | NavigationStateRoute; export interface NavigationLeafRoute { /** @@ -109,9 +100,7 @@ export interface NavigationLeafRoute { params?: Params; } -export type NavigationStateRoute< - NavigationLeafRouteParams - > = NavigationLeafRoute & NavigationState; +export type NavigationStateRoute = NavigationLeafRoute & NavigationState; export type NavigationScreenOptionsGetter = ( navigation: NavigationScreenProp>, @@ -124,10 +113,7 @@ export interface NavigationRouter { * an optional previous state. When the action is considered handled but the * state is unchanged, the output state is null. */ - getStateForAction: ( - action: NavigationAction, - lastState?: State - ) => State | null; + getStateForAction: (action: NavigationAction, lastState?: State) => (State | null); /** * Maps a URI-like string to an action. This can be mapped to a state @@ -136,14 +122,14 @@ export interface NavigationRouter { getActionForPathAndParams: ( path: string, params?: NavigationParams - ) => NavigationAction | null; + ) => (NavigationAction | null); getPathAndParamsForState: ( state: State ) => { - path: string; - params?: NavigationParams; - }; + path: string, + params?: NavigationParams, + }; getComponentForRouteName: (routeName: string) => NavigationComponent; @@ -161,8 +147,11 @@ export interface NavigationRouter { } export type NavigationScreenOption = - | T - | ((navigation: NavigationScreenProp, config: T) => T); + T + | (( + navigation: NavigationScreenProp, + config: T + ) => T); export interface NavigationScreenDetails { options: T; @@ -170,9 +159,7 @@ export interface NavigationScreenDetails { navigation: NavigationScreenProp; } -export type NavigationScreenOptions = NavigationStackScreenOptions & - NavigationTabScreenOptions & - NavigationDrawerScreenOptions; +export type NavigationScreenOptions = NavigationStackScreenOptions & NavigationTabScreenOptions & NavigationDrawerScreenOptions; export interface NavigationScreenConfigProps { navigation: NavigationScreenProp; @@ -180,34 +167,30 @@ export interface NavigationScreenConfigProps { } export type NavigationScreenConfig = - | Options - | (( - navigationOptionsContainer: NavigationScreenConfigProps & { - navigationOptions: NavigationScreenProp; - } - ) => Options); + Options + | ((navigationOptionsContainer: NavigationScreenConfigProps & { + navigationOptions: NavigationScreenProp, + }) => Options); export type NavigationComponent = - | NavigationScreenComponent - | NavigationNavigator - | any; + NavigationScreenComponent + | NavigationNavigator; export type NavigationScreenComponent< - Params = NavigationParams, - Options = {}, - Props = {} - > = React.ComponentType & Props> & { - navigationOptions?: NavigationScreenConfig; - }; + Params = NavigationParams, + Options = {}, + Props = {} +> = React.ComponentType & Props> & +{ navigationOptions?: NavigationScreenConfig }; export type NavigationNavigator< - State = NavigationState, - Options = {}, - Props = {} - > = React.ComponentType & Props> & { - router: NavigationRouter; - navigationOptions?: NavigationScreenConfig; - }; + State = NavigationState, + Options = {}, + Props = {} +> = React.ComponentType & Props> & { + router: NavigationRouter, + navigationOptions?: NavigationScreenConfig, +}; export interface NavigationParams { [key: string]: any; @@ -223,8 +206,7 @@ export interface NavigationNavigateActionPayload { key?: string; } -export interface NavigationNavigateAction - extends NavigationNavigateActionPayload { +export interface NavigationNavigateAction extends NavigationNavigateActionPayload { type: 'Navigation/NAVIGATE'; } @@ -244,8 +226,7 @@ export interface NavigationSetParamsActionPayload { params?: NavigationParams; } -export interface NavigationSetParamsAction - extends NavigationSetParamsActionPayload { +export interface NavigationSetParamsAction extends NavigationSetParamsActionPayload { type: 'Navigation/SET_PARAMS'; } @@ -290,69 +271,40 @@ export interface NavigationPopToTopActionPayload { immediate?: boolean; } -export interface NavigationPopToTopAction - extends NavigationPopToTopActionPayload { +export interface NavigationPopToTopAction extends NavigationPopToTopActionPayload { type: 'Navigation/POP_TO_TOP'; } export interface NavigationStackViewConfig { mode?: 'card' | 'modal'; headerMode?: HeaderMode; - headerTransitionPreset?: 'fade-in-place' | 'uikit'; cardStyle?: StyleProp; transitionConfig?: ( transitionProps: NavigationTransitionProps, prevTransitionProps: NavigationTransitionProps, - isModal: boolean + isModal: boolean, ) => TransitionConfig; - onTransitionStart?: ( - transitionProps: NavigationTransitionProps, - prevTransitionProps?: NavigationTransitionProps - ) => Promise | void; - onTransitionEnd?: ( - transitionProps: NavigationTransitionProps, - prevTransitionProps?: NavigationTransitionProps - ) => void; -} - -/** - * Switch Navigator - */ - -export interface NavigationSwitchRouterConfig { - initialRouteName?: string; - initialRouteParams?: NavigationParams; - paths?: NavigationPathsConfig; - navigationOptions?: NavigationScreenConfig; - order?: string[]; - backBehavior?: 'none' | 'initialRoute'; // defaults to `'none'` - resetOnBlur?: boolean; // defaults to `true` + onTransitionStart?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => Promise | void; + onTransitionEnd?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => void; } export interface NavigationStackScreenOptions { title?: string; - header?: - | ( - | React.ReactElement - | ((headerProps: HeaderProps) => React.ReactElement)) - | null; + header?: (React.ReactElement | ((headerProps: HeaderProps) => React.ReactElement)) | null; headerTransparent?: boolean; headerTitle?: string | React.ReactElement; headerTitleStyle?: StyleProp; headerTintColor?: string; headerLeft?: React.ReactElement; headerBackTitle?: string | null; - headerBackImage?: React.ReactElement; headerTruncatedBackTitle?: string; headerBackTitleStyle?: StyleProp; headerPressColorAndroid?: string; headerRight?: React.ReactElement; headerStyle?: StyleProp; - headerForceInset?: HeaderForceInset; headerBackground?: React.ReactNode | React.ReactType; gesturesEnabled?: boolean; gestureResponseDistance?: { vertical?: number; horizontal?: number }; - gestureDirection?: 'default' | 'inverted'; } export interface NavigationStackRouterConfig { @@ -365,7 +317,7 @@ export interface NavigationStackRouterConfig { } export type NavigationStackAction = - | NavigationInitAction + NavigationInitAction | NavigationNavigateAction | NavigationBackAction | NavigationSetParamsAction @@ -374,30 +326,25 @@ export type NavigationStackAction = | NavigationPopToTopAction; export type NavigationTabAction = - | NavigationInitAction + NavigationInitAction | NavigationNavigateAction | NavigationBackAction; export type NavigationAction = - | NavigationInitAction + NavigationInitAction | NavigationStackAction | NavigationTabAction; -export type NavigationRouteConfig = - | NavigationComponent - | ({ - navigationOptions?: NavigationScreenConfig; - path?: string; - } & NavigationScreenRouteConfig); +export type NavigationRouteConfig = NavigationComponent | ({ + navigationOptions?: NavigationScreenConfig, + path?: string, +} & NavigationScreenRouteConfig); -export type NavigationScreenRouteConfig = - | NavigationComponent - | { - screen: NavigationComponent; - } - | { - getScreen: () => NavigationComponent; - }; +export type NavigationScreenRouteConfig = NavigationComponent | { + screen: NavigationComponent, +} | { + getScreen: () => NavigationComponent, +}; export interface NavigationPathsConfig { [routeName: string]: string; @@ -413,48 +360,45 @@ export interface NavigationTabRouterConfig { backBehavior?: 'none' | 'initialRoute'; // defaults `initialRoute` } export interface TabScene { - route: NavigationRoute; - focused: boolean; - index: number; - tintColor?: string; + route: NavigationRoute; + focused: boolean; + index: number; + tintColor?: string; } export interface NavigationTabScreenOptions { title?: string; tabBarIcon?: - | React.ReactElement - | (( - options: { tintColor: string | null; focused: boolean } - ) => React.ReactElement | null); + React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)); tabBarLabel?: - | string - | React.ReactElement - | (( - options: { tintColor: string | null; focused: boolean } - ) => React.ReactElement | string | null); + string + | React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | string | null)); tabBarVisible?: boolean; - tabBarTestIDProps?: { testID?: string; accessibilityLabel?: string }; - tabBarOnPress?: ( - options: { - scene: TabScene; - jumpToIndex: (index: number) => void; - } - ) => void; + tabBarTestIDProps?: { testID?: string, accessibilityLabel?: string }; + tabBarOnPress?: (options: { + scene: TabScene, + jumpToIndex: (index: number) => void + }) => void; } export interface NavigationDrawerScreenOptions { title?: string; drawerIcon?: - | React.ReactElement - | (( - options: { tintColor: string | null; focused: boolean } - ) => React.ReactElement | null); + React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)); drawerLabel?: - | string - | React.ReactElement - | (( - options: { tintColor: string | null; focused: boolean } - ) => React.ReactElement | null); - drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open'; + string + | React.ReactElement + | ((options: { tintColor: (string | null), focused: boolean }) => (React.ReactElement< + any + > | null)); } export interface NavigationRouteConfigMap { @@ -469,20 +413,22 @@ export interface NavigationProp { } export type EventType = - | 'willFocus' - | 'didFocus' - | 'willBlur' - | 'didBlur' - | 'action'; +| 'willFocus' +| 'didFocus' +| 'willBlur' +| 'didBlur' +| 'action'; export interface NavigationEventPayload { type: EventType; action: NavigationAction; state: NavigationState; - lastState: NavigationState | null | undefined; + lastState: NavigationState; } -export type NavigationEventCallback = (payload: NavigationEventPayload) => void; +export type NavigationEventCallback = ( + payload: NavigationEventPayload +) => void; export interface NavigationEventSubscription { remove: () => void; @@ -492,14 +438,8 @@ export interface NavigationScreenProp { state: S; dispatch: NavigationDispatch; goBack: (routeKey?: string | null) => boolean; - dismiss: () => boolean; navigate(options: { - routeName: string | { - routeName: string; - params?: NavigationParams; - action?: NavigationNavigateAction; - key?: string; - }; + routeName: string; params?: NavigationParams; action?: NavigationAction; key?: string; @@ -507,7 +447,7 @@ export interface NavigationScreenProp { navigate( routeNameOrOptions: string, params?: NavigationParams, - action?: NavigationAction + action?: NavigationAction, ): boolean; getParam: (param: T, fallback?: P[T]) => P[T]; setParams: (newParams: P) => boolean; @@ -527,7 +467,6 @@ export interface NavigationScreenProp { ) => boolean; pop: (n?: number, params?: { immediate?: boolean }) => boolean; popToTop: (params?: { immediate?: boolean }) => boolean; - isFocused: () => boolean; } export interface NavigationNavigatorProps { @@ -619,7 +558,7 @@ export type NavigationAnimationSetter = ( lastState: NavigationState ) => void; -export type NavigationSceneRenderer = () => React.ReactElement | null; +export type NavigationSceneRenderer = () => (React.ReactElement | null); export type NavigationStyleInterpolator = ( props: NavigationSceneRendererProps @@ -628,49 +567,50 @@ export type NavigationStyleInterpolator = ( export interface LayoutEvent { nativeEvent: { layout: { - x: number; - y: number; - width: number; - height: number; - }; + x: number, + y: number, + width: number, + height: number, + }, }; } export type NavigatorType = - | 'react-navigation/STACK' - | 'react-navigation/TABS' - | 'react-navigation/DRAWER'; +| 'react-navigation/STACK' +| 'react-navigation/TABS' +| 'react-navigation/DRAWER'; -export interface NavigationContainerProps { +export function addNavigationHelpers( + navigation: { + state: S; + dispatch: (action: NavigationAction) => any; + addListener?: ( + eventName: string, + callback: NavigationEventCallback + ) => NavigationEventSubscription; + } +): NavigationScreenProp; + +export interface NavigationContainerProps { uriPrefix?: string | RegExp; onNavigationStateChange?: ( prevNavigationState: NavigationState, nextNavigationState: NavigationState, - action: NavigationAction - ) => void | null | undefined; - navigation?: NavigationScreenProp; - persistenceKey?: string | null | undefined; - renderLoadingExperimental?: React.ComponentType<{}>, - screenProps?: any; - navigationOptions?: O; + action: NavigationAction, + ) => void; style?: StyleProp; } -export interface NavigationContainerComponent - extends React.Component< +export interface NavigationContainerComponent extends React.Component< NavigationContainerProps & NavigationNavigatorProps > { dispatch: NavigationDispatch; } -export interface NavigationContainer - extends React.ComponentClass< +export interface NavigationContainer extends React.ComponentClass< NavigationContainerProps & NavigationNavigatorProps > { - new( - props: NavigationContainerProps & NavigationNavigatorProps, - context?: any - ): NavigationContainerComponent; + new(props: NavigationContainerProps & NavigationNavigatorProps, context?: any): NavigationContainerComponent; router: NavigationRouter; screenProps: { [key: string]: any }; @@ -678,43 +618,29 @@ export interface NavigationContainer state: { nav: NavigationState | null }; } -export interface StackNavigatorConfig - extends NavigationStackViewConfig, - NavigationStackRouterConfig { +export interface StackNavigatorConfig extends NavigationStackViewConfig, NavigationStackRouterConfig { containerOptions?: any; } // Return createNavigationContainer export function StackNavigator( routeConfigMap: NavigationRouteConfigMap, - stackConfig?: StackNavigatorConfig -): NavigationContainer; - -export function createStackNavigator( - routeConfigMap: NavigationRouteConfigMap, - stackConfig?: StackNavigatorConfig + stackConfig?: StackNavigatorConfig, ): NavigationContainer; export interface SwitchNavigatorConfig { initialRouteName: string; resetOnBlur?: boolean; paths?: NavigationPathsConfig; - backBehavior?: 'none' | 'intialRoute'; + backBehavior?: 'none' | 'initialRoute'; } // Return createNavigationContainer -export type _SwitchNavigatorConfig = NavigationSwitchRouterConfig; - export function SwitchNavigator( routeConfigMap: NavigationRouteConfigMap, switchConfig?: SwitchNavigatorConfig ): NavigationContainer; -export function createSwitchNavigator( - routeConfigMap: NavigationRouteConfigMap, - switchConfig?: SwitchNavigatorConfig -): NavigationContainer; - // DrawerItems export const DrawerItems: React.ReactType; @@ -729,28 +655,21 @@ export interface DrawerViewConfig { contentOptions?: any; style?: StyleProp; } -export interface DrawerNavigatorConfig - extends NavigationTabRouterConfig, - DrawerViewConfig { +export interface DrawerNavigatorConfig extends NavigationTabRouterConfig, DrawerViewConfig { containerConfig?: any; contentOptions?: { - activeTintColor?: string; - activeBackgroundColor?: string; - inactiveTintColor?: string; - inactiveBackgroundColor?: string; - style?: StyleProp; - labelStyle?: StyleProp; + activeTintColor?: string, + activeBackgroundColor?: string, + inactiveTintColor?: string, + inactiveBackgroundColor?: string, + style?: StyleProp, + labelStyle?: StyleProp, }; } export function DrawerNavigator( routeConfigMap: NavigationRouteConfigMap, - drawerConfig?: DrawerNavigatorConfig -): NavigationContainer; - -export function createDrawerNavigator( - routeConfigMap: NavigationRouteConfigMap, - drawerConfig?: DrawerNavigatorConfig + drawerConfig?: DrawerNavigatorConfig, ): NavigationContainer; /** @@ -762,23 +681,23 @@ export interface TabViewConfig { tabBarComponent?: React.ReactType; tabBarPosition?: 'top' | 'bottom'; tabBarOptions?: { - activeTintColor?: string; - allowFontScaling?: boolean; - activeBackgroundColor?: string; - inactiveTintColor?: string; - inactiveBackgroundColor?: string; - showLabel?: boolean; - style?: StyleProp; - labelStyle?: StyleProp; - iconStyle?: StyleProp; + activeTintColor?: string, + allowFontScaling?: boolean, + activeBackgroundColor?: string, + inactiveTintColor?: string, + inactiveBackgroundColor?: string, + showLabel?: boolean, + style?: StyleProp, + labelStyle?: StyleProp, + iconStyle?: StyleProp, // Top - showIcon?: boolean; - upperCaseLabel?: boolean; - pressColor?: string; - pressOpacity?: number; - scrollEnabled?: boolean; - tabStyle?: StyleProp; - indicatorStyle?: StyleProp; + showIcon?: boolean, + upperCaseLabel?: boolean, + pressColor?: string, + pressOpacity?: number, + scrollEnabled?: boolean, + tabStyle?: StyleProp, + indicatorStyle?: StyleProp, }; swipeEnabled?: boolean; animationEnabled?: boolean; @@ -786,33 +705,16 @@ export interface TabViewConfig { } // From navigators/TabNavigator.js -export interface TabNavigatorConfig - extends NavigationTabRouterConfig, - TabViewConfig { +export interface TabNavigatorConfig extends NavigationTabRouterConfig, TabViewConfig { lazy?: boolean; removeClippedSubviews?: boolean; - initialLayout?: { height: number; width: number }; + initialLayout?: { height: number, width: number }; } // From navigators/TabNavigator.js export function TabNavigator( routeConfigMap: NavigationRouteConfigMap, - drawConfig?: TabNavigatorConfig -): NavigationContainer; - -export function createTabNavigator( - routeConfigMap: NavigationRouteConfigMap, - drawConfig?: TabNavigatorConfig -): NavigationContainer; - -export function createBottomTabNavigator( - routeConfigMap: NavigationRouteConfigMap, - drawConfig?: TabNavigatorConfig -): NavigationContainer; - -export function createMaterialTopNavigator( - routeConfigMap: NavigationRouteConfigMap, - drawConfig?: TabNavigatorConfig + drawConfig?: TabNavigatorConfig, ): NavigationContainer; export interface TabBarTopProps { @@ -827,17 +729,15 @@ export interface TabBarTopProps { tabBarPosition: string; navigation: NavigationScreenProp; jumpToIndex: (index: number) => void; - getLabel: (scene: TabScene) => React.ReactNode | string; + getLabel: (scene: TabScene) => (React.ReactNode | string); getOnPress: ( previousScene: NavigationRoute, scene: TabScene - ) => ( - args: { - previousScene: NavigationRoute; - scene: TabScene; - jumpToIndex: (index: number) => void; - } - ) => void; + ) => (args: { + previousScene: NavigationRoute, + scene: TabScene, + jumpToIndex: (index: number) => void, + }) => void; renderIcon: (scene: TabScene) => React.ReactElement; labelStyle?: TextStyle; iconStyle?: ViewStyle; @@ -854,17 +754,15 @@ export interface TabBarBottomProps { position: AnimatedValue; navigation: NavigationScreenProp; jumpToIndex: (index: number) => void; - getLabel: (scene: TabScene) => React.ReactNode | string; + getLabel: (scene: TabScene) => (React.ReactNode | string); getOnPress: ( previousScene: NavigationRoute, scene: TabScene - ) => ( - args: { - previousScene: NavigationRoute; - scene: TabScene; - jumpToIndex: (index: number) => void; - } - ) => void; + ) => (args: { + previousScene: NavigationRoute, + scene: TabScene, + jumpToIndex: (index: number) => void, + }) => void; getTestIDProps: (scene: TabScene) => (scene: TabScene) => any; renderIcon: (scene: TabScene) => React.ReactNode; style?: ViewStyle; @@ -891,18 +789,12 @@ export namespace NavigationActions { const POP_TO_TOP: 'Navigation/POP_TO_TOP'; function init(options?: NavigationInitActionPayload): NavigationInitAction; - function navigate( - options: NavigationNavigateActionPayload - ): NavigationNavigateAction; + function navigate(options: NavigationNavigateActionPayload): NavigationNavigateAction; function reset(options: NavigationResetActionPayload): NavigationResetAction; function back(options?: NavigationBackActionPayload): NavigationBackAction; - function setParams( - options: NavigationSetParamsActionPayload - ): NavigationSetParamsAction; + function setParams(options: NavigationSetParamsActionPayload): NavigationSetParamsAction; function pop(options: NavigationPopActionPayload): NavigationPopAction; - function popToTop( - options: NavigationPopToTopActionPayload - ): NavigationPopToTopAction; + function popToTop(options: NavigationPopToTopActionPayload): NavigationPopToTopAction; } /** @@ -915,14 +807,8 @@ export interface TransitionerProps { prevTransitionProps?: NavigationTransitionProps ) => NavigationTransitionSpec; navigation: NavigationScreenProp; - onTransitionStart?: ( - transitionProps: NavigationTransitionProps, - prevTransitionProps?: NavigationTransitionProps - ) => Promise | void; - onTransitionEnd?: ( - transitionProps: NavigationTransitionProps, - prevTransitionProps?: NavigationTransitionProps - ) => void; + onTransitionStart?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => Promise | void; + onTransitionEnd?: (transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps) => void; render: ( transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps @@ -940,7 +826,7 @@ export interface TransitionerState { export class Transitioner extends React.Component< TransitionerProps, TransitionerState - > { } +> { } /** * Tab Router @@ -967,23 +853,12 @@ export function StackRouter( * * @see https://github.com/react-navigation/react-navigation/blob/master/src/navigators/createNavigator.js */ -export interface NavigationDescriptor { - key: string; - state: NavigationLeafRoute | NavigationStateRoute; - navigation: NavigationScreenProp; - getComponent: () => React.ComponentType<{}>; -} - -export type NavigationView = React.ComponentType<{ - descriptors: { [key: string]: NavigationDescriptor }; -} & NavigationInjectedProps>; - export function createNavigator( - view: NavigationView, router: NavigationRouter, + routeConfigs?: NavigationRouteConfigMap, navigatorConfig?: {} | null, navigatorType?: NavigatorType -): any; +): (NavigationView: React.ComponentClass) => NavigationNavigator; /** * Create an HOC that injects the navigation and manages the navigation state @@ -1004,10 +879,7 @@ export function createNavigationContainer( * BEGIN CUSTOM CONVENIENCE INTERFACES */ -export interface NavigationScreenProps< - Params = NavigationParams, - Options = any - > { +export interface NavigationScreenProps { navigation: NavigationScreenProp, Params>; screenProps?: { [key: string]: any }; navigationOptions?: NavigationScreenConfig; @@ -1064,7 +936,6 @@ export interface SafeAreaViewProps extends ViewProps { horizontal?: SafeAreaViewForceInsetValue; vertical?: SafeAreaViewForceInsetValue; }; - children?: React.ReactNode; } export const SafeAreaView: React.ComponentClass; diff --git a/types/react-navigation/v2/index.d.ts b/types/react-navigation/v2/index.d.ts new file mode 100644 index 0000000000..36251eba5b --- /dev/null +++ b/types/react-navigation/v2/index.d.ts @@ -0,0 +1,1086 @@ +// Type definitions for react-navigation 2.0 +// Project: https://github.com/react-navigation/react-navigation +// Definitions by: Huhuanming +// mhcgrq +// fangpenlin +// petejkim +// Kyle Roach +// phanalpha +// charlesfamu +// Tim Wang +// Qibang Sun +// Sergei Butko: +// Veit Lehmann: +// Roberto Huertas: +// Steven Miller +// Armando Assuncao +// Ciaran Liedeman +// Edward Sammut Alessi +// Jérémy Magrin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/** + * Reference: https://github.com/react-navigation/react-navigation/tree/a37473c5e4833f48796ee6c7c9cb4a8ac49d9c06 + * + * NOTE: Please update the commit/link above when updating to a new Flow + * react-navigation/flow/react-navigation.js reference, so we can conveniently just look at diffs on + * react-navigation/flow/react-navigation.js between this latest reference point and the one you are + * using when making new updates. + */ + +import * as React from 'react'; +import { + Animated, + TextStyle, + ViewProps, + ViewStyle, + StyleProp, +} from 'react-native'; + +// @todo when we split types into common, native and web, +// we can properly change Animated.Value to its real value +export type AnimatedValue = any; + +export type HeaderMode = 'float' | 'screen' | 'none'; + +export interface HeaderForceInset { + horizontal?: string; + vertical?: string, + left?: string, + right?: string, + top?: string, + bottom?: string, +} + +export interface HeaderProps extends NavigationSceneRendererProps { + mode: HeaderMode; + router: NavigationRouter; + getScreenDetails: ( + navigationScene: NavigationScene + ) => NavigationScreenDetails; + leftInterpolator: (props: NavigationSceneRendererProps) => {}; + titleInterpolator: (props: NavigationSceneRendererProps) => {}; + rightInterpolator: (props: NavigationSceneRendererProps) => {}; + style: StyleProp; +} + +/** + * NavigationState is a tree of routes for a single navigator, where each child + * route may either be a NavigationScreenRoute or a NavigationRouterRoute. + * NavigationScreenRoute represents a leaf screen, while the + * NavigationRouterRoute represents the state of a child navigator. + * + * NOTE: NavigationState is a state tree local to a single navigator and + * its child navigators (via the routes field). + * If we're in navigator nested deep inside the app, the state will only be the + * state for that navigator. + * The state for the root navigator of our app represents the whole navigation + * state for the whole app. + */ +export interface NavigationState { + /** + * Index refers to the active child route in the routes array. + */ + index: number; + routes: NavigationRoute[]; +} + +export type NavigationRoute = + | NavigationLeafRoute + | NavigationStateRoute; + +export interface NavigationLeafRoute { + /** + * React's key used by some navigators. No need to specify these manually, + * they will be defined by the router. + */ + key: string; + /** + * For example 'Home'. + * This is used as a key in a route config when creating a navigator. + */ + routeName: string; + /** + * Path is an advanced feature used for deep linking and on the web. + */ + path?: string; + /** + * Params passed to this route when navigating to it, + * e.g. `{ car_id: 123 }` in a route that displays a car. + */ + params?: Params; +} + +export type NavigationStateRoute< + NavigationLeafRouteParams + > = NavigationLeafRoute & NavigationState; + +export type NavigationScreenOptionsGetter = ( + navigation: NavigationScreenProp>, + screenProps?: { [key: string]: any } +) => Options; + +export interface NavigationRouter { + /** + * The reducer that outputs the new navigation state for a given action, with + * an optional previous state. When the action is considered handled but the + * state is unchanged, the output state is null. + */ + getStateForAction: ( + action: NavigationAction, + lastState?: State + ) => State | null; + + /** + * Maps a URI-like string to an action. This can be mapped to a state + * using `getStateForAction`. + */ + getActionForPathAndParams: ( + path: string, + params?: NavigationParams + ) => NavigationAction | null; + + getPathAndParamsForState: ( + state: State + ) => { + path: string; + params?: NavigationParams; + }; + + getComponentForRouteName: (routeName: string) => NavigationComponent; + + getComponentForState: (state: State) => NavigationComponent; + + /** + * Gets the screen navigation options for a given screen. + * + * For example, we could get the config for the 'Foo' screen when the + * `navigation.state` is: + * + * {routeName: 'Foo', key: '123'} + */ + getScreenOptions: NavigationScreenOptionsGetter; +} + +export type NavigationScreenOption = + | T + | ((navigation: NavigationScreenProp, config: T) => T); + +export interface NavigationScreenDetails { + options: T; + state: NavigationRoute; + navigation: NavigationScreenProp; +} + +export type NavigationScreenOptions = NavigationStackScreenOptions & + NavigationTabScreenOptions & + NavigationDrawerScreenOptions; + +export interface NavigationScreenConfigProps { + navigation: NavigationScreenProp; + screenProps: { [key: string]: any }; +} + +export type NavigationScreenConfig = + | Options + | (( + navigationOptionsContainer: NavigationScreenConfigProps & { + navigationOptions: NavigationScreenProp; + } + ) => Options); + +export type NavigationComponent = + | NavigationScreenComponent + | NavigationNavigator + | any; + +export type NavigationScreenComponent< + Params = NavigationParams, + Options = {}, + Props = {} + > = React.ComponentType & Props> & { + navigationOptions?: NavigationScreenConfig; + }; + +export type NavigationNavigator< + State = NavigationState, + Options = {}, + Props = {} + > = React.ComponentType & Props> & { + router: NavigationRouter; + navigationOptions?: NavigationScreenConfig; + }; + +export interface NavigationParams { + [key: string]: any; +} + +export interface NavigationNavigateActionPayload { + routeName: string; + params?: NavigationParams; + + // The action to run inside the sub-router + action?: NavigationNavigateAction; + + key?: string; +} + +export interface NavigationNavigateAction + extends NavigationNavigateActionPayload { + type: 'Navigation/NAVIGATE'; +} + +export interface NavigationBackActionPayload { + key?: string | null; +} + +export interface NavigationBackAction extends NavigationBackActionPayload { + type: 'Navigation/BACK'; +} + +export interface NavigationSetParamsActionPayload { + // The key of the route where the params should be set + key: string; + + // The new params to merge into the existing route params + params?: NavigationParams; +} + +export interface NavigationSetParamsAction + extends NavigationSetParamsActionPayload { + type: 'Navigation/SET_PARAMS'; +} + +export interface NavigationInitActionPayload { + params?: NavigationParams; +} + +export interface NavigationInitAction extends NavigationInitActionPayload { + type: 'Navigation/INIT'; +} + +export interface NavigationResetActionPayload { + index: number; + key?: string | null; + actions: NavigationNavigateAction[]; +} + +export interface NavigationResetAction extends NavigationResetActionPayload { + type: 'Navigation/RESET'; +} + +export interface NavigationUriActionPayload { + uri: string; +} + +export interface NavigationUriAction extends NavigationUriActionPayload { + type: 'Navigation/URI'; +} + +export interface NavigationPopActionPayload { + // n: the number of routes to pop of the stack + n?: number; + immediate?: boolean; +} + +export interface NavigationPopAction extends NavigationPopActionPayload { + type: 'Navigation/POP'; +} + +export interface NavigationPopToTopActionPayload { + key?: string; + immediate?: boolean; +} + +export interface NavigationPopToTopAction + extends NavigationPopToTopActionPayload { + type: 'Navigation/POP_TO_TOP'; +} + +export interface NavigationStackViewConfig { + mode?: 'card' | 'modal'; + headerMode?: HeaderMode; + headerTransitionPreset?: 'fade-in-place' | 'uikit'; + cardStyle?: StyleProp; + transitionConfig?: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps: NavigationTransitionProps, + isModal: boolean + ) => TransitionConfig; + onTransitionStart?: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps?: NavigationTransitionProps + ) => Promise | void; + onTransitionEnd?: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps?: NavigationTransitionProps + ) => void; +} + +/** + * Switch Navigator + */ + +export interface NavigationSwitchRouterConfig { + initialRouteName?: string; + initialRouteParams?: NavigationParams; + paths?: NavigationPathsConfig; + navigationOptions?: NavigationScreenConfig; + order?: string[]; + backBehavior?: 'none' | 'initialRoute'; // defaults to `'none'` + resetOnBlur?: boolean; // defaults to `true` +} + +export interface NavigationStackScreenOptions { + title?: string; + header?: + | ( + | React.ReactElement + | ((headerProps: HeaderProps) => React.ReactElement)) + | null; + headerTransparent?: boolean; + headerTitle?: string | React.ReactElement; + headerTitleStyle?: StyleProp; + headerTitleAllowFontScaling?: boolean; + headerTintColor?: string; + headerLeft?: React.ReactElement; + headerBackTitle?: string | null; + headerBackImage?: React.ReactElement; + headerTruncatedBackTitle?: string; + headerBackTitleStyle?: StyleProp; + headerPressColorAndroid?: string; + headerRight?: React.ReactElement; + headerStyle?: StyleProp; + headerForceInset?: HeaderForceInset; + headerBackground?: React.ReactNode | React.ReactType; + gesturesEnabled?: boolean; + gestureResponseDistance?: { vertical?: number; horizontal?: number }; + gestureDirection?: 'default' | 'inverted'; +} + +export interface NavigationStackRouterConfig { + headerTransitionPreset?: 'fade-in-place' | 'uikit'; + initialRouteName?: string; + initialRouteParams?: NavigationParams; + paths?: NavigationPathsConfig; + navigationOptions?: NavigationScreenConfig; + initialRouteKey?: string; +} + +export type NavigationStackAction = + | NavigationInitAction + | NavigationNavigateAction + | NavigationBackAction + | NavigationSetParamsAction + | NavigationResetAction + | NavigationPopAction + | NavigationPopToTopAction; + +export type NavigationTabAction = + | NavigationInitAction + | NavigationNavigateAction + | NavigationBackAction; + +export type NavigationAction = + | NavigationInitAction + | NavigationStackAction + | NavigationTabAction; + +export type NavigationRouteConfig = + | NavigationComponent + | ({ + navigationOptions?: NavigationScreenConfig; + path?: string; + } & NavigationScreenRouteConfig); + +export type NavigationScreenRouteConfig = + | NavigationComponent + | { + screen: NavigationComponent; + } + | { + getScreen: () => NavigationComponent; + }; + +export interface NavigationPathsConfig { + [routeName: string]: string; +} + +export interface NavigationTabRouterConfig { + initialRouteName?: string; + initialRouteParams?: NavigationParams; + paths?: NavigationPathsConfig; + navigationOptions?: NavigationScreenConfig; + order?: string[]; // todo: type these as the real route names rather than 'string' + + // Does the back button cause the router to switch to the initial tab + backBehavior?: 'none' | 'initialRoute'; // defaults `initialRoute` +} +export interface TabScene { + route: NavigationRoute; + focused: boolean; + index: number; + tintColor?: string; +} +export interface NavigationTabScreenOptions { + title?: string; + tabBarIcon?: + | React.ReactElement + | (( + options: { tintColor: string | null; focused: boolean } + ) => React.ReactElement | null); + tabBarLabel?: + | string + | React.ReactElement + | (( + options: { tintColor: string | null; focused: boolean } + ) => React.ReactElement | string | null); + tabBarVisible?: boolean; + tabBarTestIDProps?: { testID?: string; accessibilityLabel?: string }; + tabBarOnPress?: ( + options: { + scene: TabScene; + jumpToIndex: (index: number) => void; + } + ) => void; +} + +export interface NavigationDrawerScreenOptions { + title?: string; + drawerIcon?: + | React.ReactElement + | (( + options: { tintColor: string | null; focused: boolean } + ) => React.ReactElement | null); + drawerLabel?: + | string + | React.ReactElement + | (( + options: { tintColor: string | null; focused: boolean } + ) => React.ReactElement | null); + drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open'; +} + +export interface NavigationRouteConfigMap { + [routeName: string]: NavigationRouteConfig; +} + +export type NavigationDispatch = (action: NavigationAction) => boolean; + +export interface NavigationProp { + state: S; + dispatch: NavigationDispatch; +} + +export type EventType = + | 'willFocus' + | 'didFocus' + | 'willBlur' + | 'didBlur' + | 'action'; + +export interface NavigationEventPayload { + type: EventType; + action: NavigationAction; + state: NavigationState; + lastState: NavigationState | null | undefined; +} + +export type NavigationEventCallback = (payload: NavigationEventPayload) => void; + +export interface NavigationEventSubscription { + remove: () => void; +} + +export interface NavigationScreenProp { + state: S; + dispatch: NavigationDispatch; + goBack: (routeKey?: string | null) => boolean; + dismiss: () => boolean; + navigate(options: { + routeName: string | { + routeName: string; + params?: NavigationParams; + action?: NavigationNavigateAction; + key?: string; + }; + params?: NavigationParams; + action?: NavigationAction; + key?: string; + }): boolean; + navigate( + routeNameOrOptions: string, + params?: NavigationParams, + action?: NavigationAction + ): boolean; + openDrawer: () => any; + closeDrawer: () => any; + toggleDrawer: () => any; + getParam: (param: T, fallback?: P[T]) => P[T]; + setParams: (newParams: P) => boolean; + addListener: ( + eventName: string, + callback: NavigationEventCallback + ) => NavigationEventSubscription; + push: ( + routeName: string, + params?: NavigationParams, + action?: NavigationNavigateAction + ) => boolean; + replace: ( + routeName: string, + params?: NavigationParams, + action?: NavigationNavigateAction + ) => boolean; + pop: (n?: number, params?: { immediate?: boolean }) => boolean; + popToTop: (params?: { immediate?: boolean }) => boolean; + isFocused: () => boolean; +} + +export interface NavigationNavigatorProps { + navigation?: NavigationProp; + screenProps?: { [key: string]: any }; + navigationOptions?: O; +} + +/** + * Gestures, Animations, and Interpolators + */ + +export type NavigationGestureDirection = 'horizontal' | 'vertical'; + +export interface NavigationLayout { + height: AnimatedValue; + initHeight: number; + initWidth: number; + isMeasured: boolean; + width: AnimatedValue; +} + +export interface NavigationScene { + index: number; + isActive: boolean; + isStale: boolean; + key: string; + route: NavigationRoute; +} + +export interface NavigationTransitionProps { + // The layout of the screen container + layout: NavigationLayout; + + // The destination navigation state of the transition + navigation: NavigationScreenProp; + + // The progressive index of the transitioner's navigation state. + position: AnimatedValue; + + // The value that represents the progress of the transition when navigation + // state changes from one to another. Its numberic value will range from 0 + // to 1. + // progress.__getAnimatedValue() < 1 : transtion is happening. + // progress.__getAnimatedValue() == 1 : transtion completes. + progress: AnimatedValue; + + // All the scenes of the transitioner. + scenes: NavigationScene[]; + + // The active scene, corresponding to the route at + // `navigation.state.routes[navigation.state.index]`. When rendering + // NavigationSceneRendererPropsIndex, the scene does not refer to the active + // scene, but instead the scene that is being rendered. The index always + // is the index of the scene + scene: NavigationScene; + index: number; + + screenProps?: { [key: string]: any }; +} + +// The scene renderer props are nearly identical to the props used for rendering +// a transition. The exception is that the passed scene is not the active scene +// but is instead the scene that the renderer should render content for. +export type NavigationSceneRendererProps = NavigationTransitionProps; + +export interface NavigationTransitionSpec { + duration?: number; + // An easing function from `Easing`. + easing?: (t: number) => number; + // A timing function such as `Animated.timing`. + timing?: (value: AnimatedValue, config: any) => any; +} + +/** + * Describes a visual transition from one screen to another. + */ +export interface TransitionConfig { + // The basics properties of the animation, such as duration and easing + transitionSpec?: NavigationTransitionSpec; + // How to animate position and opacity of the screen + // based on the value generated by the transitionSpec + screenInterpolator?: (props: NavigationSceneRendererProps) => any; + // How to animate position and opacity of the header componetns + // based on the value generated by the transitionSpec + headerLeftInterpolator?: (props: NavigationSceneRendererProps) => any; + headerTitleInterpolator?: (props: NavigationSceneRendererProps) => any; + headerRightInterpolator?: (props: NavigationSceneRendererProps) => any; + // The style of the container. Useful when a scene doesn't have + // 100% opacity and the underlying container is visible. + containerStyle?: StyleProp; +} + +export type NavigationAnimationSetter = ( + position: AnimatedValue, + newState: NavigationState, + lastState: NavigationState +) => void; + +export type NavigationSceneRenderer = () => React.ReactElement | null; + +export type NavigationStyleInterpolator = ( + props: NavigationSceneRendererProps +) => ViewStyle; + +export interface LayoutEvent { + nativeEvent: { + layout: { + x: number; + y: number; + width: number; + height: number; + }; + }; +} + +export type NavigatorType = + | 'react-navigation/STACK' + | 'react-navigation/TABS' + | 'react-navigation/DRAWER'; + +export interface NavigationContainerProps { + uriPrefix?: string | RegExp; + onNavigationStateChange?: ( + prevNavigationState: NavigationState, + nextNavigationState: NavigationState, + action: NavigationAction + ) => void | null | undefined; + navigation?: NavigationScreenProp; + persistenceKey?: string | null | undefined; + renderLoadingExperimental?: React.ComponentType<{}>, + screenProps?: any; + navigationOptions?: O; + style?: StyleProp; +} + +export interface NavigationContainerComponent + extends React.Component< + NavigationContainerProps & NavigationNavigatorProps + > { + dispatch: NavigationDispatch; +} + +export interface NavigationContainer + extends React.ComponentClass< + NavigationContainerProps & NavigationNavigatorProps + > { + new( + props: NavigationContainerProps & NavigationNavigatorProps, + context?: any + ): NavigationContainerComponent; + + router: NavigationRouter; + screenProps: { [key: string]: any }; + navigationOptions: any; + state: { nav: NavigationState | null }; +} + +export interface StackNavigatorConfig + extends NavigationStackViewConfig, + NavigationStackRouterConfig { + containerOptions?: any; +} + +// Return createNavigationContainer +export function StackNavigator( + routeConfigMap: NavigationRouteConfigMap, + stackConfig?: StackNavigatorConfig +): NavigationContainer; + +export function createStackNavigator( + routeConfigMap: NavigationRouteConfigMap, + stackConfig?: StackNavigatorConfig +): NavigationContainer; + +export interface SwitchNavigatorConfig { + initialRouteName: string; + resetOnBlur?: boolean; + paths?: NavigationPathsConfig; + backBehavior?: 'none' | 'initialRoute'; +} + +// Return createNavigationContainer +export type _SwitchNavigatorConfig = NavigationSwitchRouterConfig; + +export function SwitchNavigator( + routeConfigMap: NavigationRouteConfigMap, + switchConfig?: SwitchNavigatorConfig +): NavigationContainer; + +export function createSwitchNavigator( + routeConfigMap: NavigationRouteConfigMap, + switchConfig?: SwitchNavigatorConfig +): NavigationContainer; + +// DrawerItems +export const DrawerItems: React.ReactType; + +/** + * Drawer Navigator + */ +export interface DrawerViewConfig { + drawerBackgroundColor?: string; + drawerWidth?: number; + drawerPosition?: 'left' | 'right'; + contentComponent?: React.ReactType; + contentOptions?: any; + style?: StyleProp; +} +export interface DrawerNavigatorConfig + extends NavigationTabRouterConfig, + DrawerViewConfig { + containerConfig?: any; + contentOptions?: { + activeTintColor?: string; + activeBackgroundColor?: string; + inactiveTintColor?: string; + inactiveBackgroundColor?: string; + style?: StyleProp; + labelStyle?: StyleProp; + }; +} + +export function DrawerNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawerConfig?: DrawerNavigatorConfig +): NavigationContainer; + +export function createDrawerNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawerConfig?: DrawerNavigatorConfig +): NavigationContainer; + +/** + * Tab Navigator + */ + +// From views/TabView/TabView.js +export interface TabViewConfig { + tabBarComponent?: React.ReactType; + tabBarPosition?: 'top' | 'bottom'; + tabBarOptions?: { + activeTintColor?: string; + allowFontScaling?: boolean; + activeBackgroundColor?: string; + inactiveTintColor?: string; + inactiveBackgroundColor?: string; + showLabel?: boolean; + style?: StyleProp; + labelStyle?: StyleProp; + iconStyle?: StyleProp; + // Top + showIcon?: boolean; + upperCaseLabel?: boolean; + pressColor?: string; + pressOpacity?: number; + scrollEnabled?: boolean; + tabStyle?: StyleProp; + indicatorStyle?: StyleProp; + }; + swipeEnabled?: boolean; + animationEnabled?: boolean; + lazy?: boolean; +} + +// From navigators/TabNavigator.js +export interface TabNavigatorConfig + extends NavigationTabRouterConfig, + TabViewConfig { + lazy?: boolean; + removeClippedSubviews?: boolean; + initialLayout?: { height: number; width: number }; +} + +// From navigators/TabNavigator.js +export function TabNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawConfig?: TabNavigatorConfig +): NavigationContainer; + +export function createTabNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawConfig?: TabNavigatorConfig +): NavigationContainer; + +export function createBottomTabNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawConfig?: TabNavigatorConfig +): NavigationContainer; + +export function createMaterialTopNavigator( + routeConfigMap: NavigationRouteConfigMap, + drawConfig?: TabNavigatorConfig +): NavigationContainer; + +export interface TabBarTopProps { + activeTintColor: string; + inactiveTintColor: string; + indicatorStyle: StyleProp; + showIcon: boolean; + showLabel: boolean; + upperCaseLabel: boolean; + allowFontScaling: boolean; + position: AnimatedValue; + tabBarPosition: string; + navigation: NavigationScreenProp; + jumpToIndex: (index: number) => void; + getLabel: (scene: TabScene) => React.ReactNode | string; + getOnPress: ( + previousScene: NavigationRoute, + scene: TabScene + ) => ( + args: { + previousScene: NavigationRoute; + scene: TabScene; + jumpToIndex: (index: number) => void; + } + ) => void; + renderIcon: (scene: TabScene) => React.ReactElement; + labelStyle?: TextStyle; + iconStyle?: ViewStyle; +} + +export interface TabBarBottomProps { + activeTintColor: string; + activeBackgroundColor: string; + adaptive?: boolean; + inactiveTintColor: string; + inactiveBackgroundColor: string; + showLabel?: boolean; + allowFontScaling: boolean; + position: AnimatedValue; + navigation: NavigationScreenProp; + jumpToIndex: (index: number) => void; + getLabel: (scene: TabScene) => React.ReactNode | string; + getOnPress: ( + previousScene: NavigationRoute, + scene: TabScene + ) => ( + args: { + previousScene: NavigationRoute; + scene: TabScene; + jumpToIndex: (index: number) => void; + } + ) => void; + getTestIDProps: (scene: TabScene) => (scene: TabScene) => any; + renderIcon: (scene: TabScene) => React.ReactNode; + style?: ViewStyle; + animateStyle?: ViewStyle; + labelStyle?: TextStyle; + tabStyle?: ViewStyle; + showIcon?: boolean; +} + +export const TabBarTop: React.ComponentType; +export const TabBarBottom: React.ComponentType; + +/** + * NavigationActions + */ +export namespace NavigationActions { + const BACK: 'Navigation/BACK'; + const INIT: 'Navigation/INIT'; + const NAVIGATE: 'Navigation/NAVIGATE'; + const RESET: 'Navigation/RESET'; + const SET_PARAMS: 'Navigation/SET_PARAMS'; + const URI: 'Navigation/URI'; + const POP: 'Navigation/POP'; + const POP_TO_TOP: 'Navigation/POP_TO_TOP'; + + function init(options?: NavigationInitActionPayload): NavigationInitAction; + function navigate( + options: NavigationNavigateActionPayload + ): NavigationNavigateAction; + function reset(options: NavigationResetActionPayload): NavigationResetAction; + function back(options?: NavigationBackActionPayload): NavigationBackAction; + function setParams( + options: NavigationSetParamsActionPayload + ): NavigationSetParamsAction; + function pop(options: NavigationPopActionPayload): NavigationPopAction; + function popToTop( + options: NavigationPopToTopActionPayload + ): NavigationPopToTopAction; +} + +/** + * Transitioner + * @desc From react-navigation/src/views/Transitioner.js + */ +export interface TransitionerProps { + configureTransition: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps?: NavigationTransitionProps + ) => NavigationTransitionSpec; + navigation: NavigationScreenProp; + onTransitionStart?: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps?: NavigationTransitionProps + ) => Promise | void; + onTransitionEnd?: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps?: NavigationTransitionProps + ) => void; + render: ( + transitionProps: NavigationTransitionProps, + prevTransitionProps?: NavigationTransitionProps + ) => any; + style?: StyleProp; +} + +export interface TransitionerState { + layout: NavigationLayout; + position: Animated.Value; + progress: Animated.Value; + scenes: NavigationScene[]; +} + +export class Transitioner extends React.Component< + TransitionerProps, + TransitionerState + > { } + +/** + * Tab Router + * + * @desc from react-navigation/src/routers/TabRouter.js + */ +export function TabRouter( + routeConfigs: NavigationRouteConfigMap, + config: NavigationTabRouterConfig +): NavigationRouter; + +/** + * Stack Router + * + * @desc from react-navigation/src/routers/StackRouter.js + */ +export function StackRouter( + routeConfigs: NavigationRouteConfigMap, + config: NavigationTabRouterConfig +): NavigationRouter; + +/** + * Create Navigator + * + * @see https://github.com/react-navigation/react-navigation/blob/master/src/navigators/createNavigator.js + */ +export interface NavigationDescriptor { + key: string; + state: NavigationLeafRoute | NavigationStateRoute; + navigation: NavigationScreenProp; + getComponent: () => React.ComponentType<{}>; +} + +export type NavigationView = React.ComponentType<{ + descriptors: { [key: string]: NavigationDescriptor }; +} & NavigationInjectedProps>; + +export function createNavigator( + view: NavigationView, + router: NavigationRouter, + navigatorConfig?: {} | null, + navigatorType?: NavigatorType +): any; + +/** + * Create an HOC that injects the navigation and manages the navigation state + * in case it's not passed from above. + * This allows to use e.g. the StackNavigator and TabNavigator as root-level + * components. + * + * @see https://github.com/react-navigation/react-navigation/blob/master/src/createNavigationContainer.js + */ +export function createNavigationContainer( + Component: NavigationNavigator +): NavigationContainer; +/** + * END MANUAL DEFINITIONS OUTSIDE OF TYPEDEFINITION.JS + */ + +/** + * BEGIN CUSTOM CONVENIENCE INTERFACES + */ + +export interface NavigationScreenProps< + Params = NavigationParams, + Options = any + > { + navigation: NavigationScreenProp, Params>; + screenProps?: { [key: string]: any }; + navigationOptions?: NavigationScreenConfig; +} + +/** + * END CUSTOM CONVENIENCE INTERFACES + */ + +/* + * Header + */ + +// src/views/HeaderBackButton.js + +export interface HeaderBackButtonProps { + onPress?: () => void; + pressColorAndroid?: string; + title?: string; + titleStyle?: StyleProp; + tintColor?: string; + truncatedTitle?: string; + width?: number; +} + +export const HeaderBackButton: React.ComponentClass; +/** + * Header Component + */ +export const Header: React.ComponentClass; + +export interface NavigationInjectedProps { + navigation: NavigationScreenProp; +} + +export function withNavigation( + Component: React.ComponentType +): React.ComponentType; + +export function withNavigationFocus( + Component: React.ComponentType +): React.ComponentType; + +/** + * SafeAreaView Component + */ +export type SafeAreaViewForceInsetValue = 'always' | 'never'; +export interface SafeAreaViewProps extends ViewProps { + forceInset?: { + top?: SafeAreaViewForceInsetValue; + bottom?: SafeAreaViewForceInsetValue; + left?: SafeAreaViewForceInsetValue; + right?: SafeAreaViewForceInsetValue; + horizontal?: SafeAreaViewForceInsetValue; + vertical?: SafeAreaViewForceInsetValue; + }; + children?: React.ReactNode; +} + +export const SafeAreaView: React.ComponentClass; diff --git a/types/react-navigation/v2/react-navigation-tests.tsx b/types/react-navigation/v2/react-navigation-tests.tsx new file mode 100644 index 0000000000..b59474bd11 --- /dev/null +++ b/types/react-navigation/v2/react-navigation-tests.tsx @@ -0,0 +1,453 @@ +import * as React from 'react'; +import { + TouchableOpacity, + View, + ViewStyle, +} from 'react-native'; +import { + createDrawerNavigator, + DrawerNavigatorConfig, + NavigationAction, + NavigationActions, + NavigationBackAction, + NavigationInitAction, + NavigationNavigateAction, + NavigationProp, + NavigationResetAction, + NavigationRouteConfigMap, + NavigationScreenProp, + NavigationScreenProps, + NavigationSetParamsAction, + NavigationStackAction, + NavigationStackScreenOptions, + NavigationTabScreenOptions, + NavigationTransitionProps, + createStackNavigator, + StackNavigatorConfig, + createSwitchNavigator, + SwitchNavigatorConfig, + TabBarTop, + createTabNavigator, + TabNavigatorConfig, + Transitioner, + HeaderBackButton, + Header, + NavigationContainer, + NavigationParams, + NavigationPopAction, + NavigationPopToTopAction, + NavigationScreenComponent, + NavigationContainerComponent, +} from 'react-navigation'; + +// Constants +const viewStyle: ViewStyle = { + flex: 1, + margin: 42, + padding: 0, + backgroundColor: "white", +}; + +const ROUTE_NAME_START_SCREEN = "StartScreen"; +const ROUTE_KEY_START_SCREEN = "StartScreen-key"; + +interface StartScreenNavigationParams { + id: number; + s: string; +} + +/** + * @desc Simple screen component class with typed component props that should + * receive the navigation prop from the AppNavigator. + */ +class StartScreen extends React.Component> { + render() { + // Implicit type checks. + const navigationStateParams: StartScreenNavigationParams | undefined = this.props.navigation.state.params; + const id = this.props.navigation.state.params && this.props.navigation.state.params.id; + const s = this.props.navigation.state.params && this.props.navigation.state.params.s; + + return ( + + + + + ); + } + private readonly navigateToNextScreen = (): void => { + const params = { + id: this.props.navigation.state.params && this.props.navigation.state.params.id, + name: this.props.navigation.state.params && this.props.navigation.state.params.s, + }; + this.props.navigation.navigate(ROUTE_NAME_NEXT_SCREEN, params); + } + private readonly navigateDifferentlyToNextScreen = (): void => { + const params = { + id: this.props.navigation.state.params && this.props.navigation.state.params.id, + name: this.props.navigation.state.params && this.props.navigation.state.params.s, + }; + this.props.navigation.navigate({routeName: ROUTE_NAME_NEXT_SCREEN, params}); + } +} + +const ROUTE_NAME_NEXT_SCREEN = "NextScreen"; + +interface NextScreenNavigationParams { + id: number; + name: string; +} + +class NextScreen extends React.Component> { + render() { + // Implicit type checks. + const navigationStateParams: NextScreenNavigationParams | undefined = this.props.navigation.state.params; + const id = this.props.navigation.state.params && this.props.navigation.state.params.id; + const name = this.props.navigation.getParam('name', 'Peter'); + + return ( + + ); + } +} + +const navigationOptions = { + headerBackTitle: null, +}; +const initialRouteParams: StartScreenNavigationParams = { + id: 1, + s: "Start", +}; +const routeConfigMap: NavigationRouteConfigMap = { + [ROUTE_NAME_START_SCREEN]: { + path: "start", + screen: StartScreen, + }, + [ROUTE_NAME_NEXT_SCREEN]: { + path: "next", + screen: NextScreen, + }, +}; +export const AppNavigator = createStackNavigator( + routeConfigMap, + { + initialRouteName: ROUTE_NAME_START_SCREEN, + initialRouteKey: ROUTE_KEY_START_SCREEN, + initialRouteParams, + navigationOptions, + }, +); + +interface StatelessScreenParams { + testID: string; +} + +const StatelessScreen: NavigationScreenComponent = (props) => + ; + +StatelessScreen.navigationOptions = { title: 'Stateless' }; + +const SimpleStackNavigator = createStackNavigator( + { + simple: { + screen: StatelessScreen, + }, + } +); + +/** + * Tab navigator. + */ + +const tabNavigatorScreenOptions: NavigationTabScreenOptions = { + title: 'title', + tabBarVisible: true, + tabBarIcon: , + tabBarLabel: 'label', + tabBarOnPress: ({scene, jumpToIndex}) => {} +}; + +const tabNavigatorConfig: TabNavigatorConfig = { + lazy: true, + tabBarComponent: TabBarTop, + tabBarOptions: { activeBackgroundColor: "blue" }, +}; + +const tabNavigatorConfigWithInitialLayout: TabNavigatorConfig = { + ...tabNavigatorConfig, + initialLayout: { height: 0, width: 100 }, +}; + +const tabNavigatorConfigWithNavigationOptions: TabNavigatorConfig = { + ...tabNavigatorConfig, + navigationOptions: { + tabBarOnPress: ({scene, jumpToIndex}) => { + jumpToIndex(scene.index); + }, + headerStyle: { + backgroundColor: 'red', + }, + }, +}; + +const BasicTabNavigator = createTabNavigator( + routeConfigMap, + tabNavigatorConfig, +); + +function renderBasicTabNavigator(): JSX.Element { + return ( + { }} + style={[viewStyle, undefined]} // Test that we are using StyleProp + /> + ); +} + +/** + * Stack navigator. + */ + +const stackNavigatorScreenOptions: NavigationStackScreenOptions = { + title: 'title', +}; + +const stackNavigatorConfig: StackNavigatorConfig = { + mode: "card", + headerMode: "screen", + navigationOptions: stackNavigatorScreenOptions, +}; + +const BasicStackNavigator = createStackNavigator( + routeConfigMap, + stackNavigatorConfig, +); + +function renderBasicStackNavigator(): JSX.Element { + return ( + { }} + style={viewStyle} + /> + ); +} + +const stackNavigatorConfigWithNavigationOptionsAsFunction: StackNavigatorConfig = { + mode: "card", + headerMode: "screen", + navigationOptions: ({navigationOptions, navigation, screenProps}) => (stackNavigatorScreenOptions), +}; + +const AdvancedStackNavigator = createStackNavigator( + routeConfigMap, + stackNavigatorConfigWithNavigationOptionsAsFunction +); + +function renderAdvancedStackNavigator(): JSX.Element { + return ( + { }} + style={viewStyle} + /> + ); +} + +/** + * Switch navigator. + */ + +const switchNavigatorConfig: SwitchNavigatorConfig = { + initialRouteName: 'screen', + resetOnBlur: false, + backBehavior: 'none' +}; + +const BasicSwitchNavigator = createSwitchNavigator( + routeConfigMap, + switchNavigatorConfig, +); + +function renderBasicSwitchNavigator(): JSX.Element { + return ( + { }} + style={viewStyle} + /> + ); +} + +const switchNavigatorConfigWithInitialRoute: SwitchNavigatorConfig = { + initialRouteName: 'screen', + resetOnBlur: false, + backBehavior: 'initialRoute' +}; + +const SwitchNavigatorWithInitialRoute = createSwitchNavigator( + routeConfigMap, + switchNavigatorConfigWithInitialRoute, +); + +function renderSwitchNavigatorWithInitialRoute(): JSX.Element { + return ( + { }} + style={viewStyle} + /> + ); +} + +/** + * Drawer navigator. + */ + +const drawerNavigatorScreenOptions: NavigationTabScreenOptions = { + title: 'title', +}; + +const drawerNavigatorConfig: DrawerNavigatorConfig = { + drawerBackgroundColor: '#777777', + contentOptions: { + activeTintColor: '#7A9B49', + inactiveTintColor: '#FFFFFF', + }, +}; + +const BasicDrawerNavigator = createDrawerNavigator( + routeConfigMap, + stackNavigatorConfig, +); + +function renderBasicDrawerNavigator(): JSX.Element { + return ( + { }} + style={viewStyle} + /> + ); +} + +interface CustomTransitionerProps { + navigation: NavigationScreenProp; +} +/** + * @desc Custom transitioner component. Follows react-navigation/src/views/CardStackTransitioner.js. + */ +class CustomTransitioner extends React.Component { + render() { + return ( + { + if (prev) { + prev.position.setValue(curr.navigation.state.index); + } + }} + onTransitionEnd={(curr, prev) => { + if (prev) { + prev.position.setValue(curr.navigation.state.index); + } + }} + /> + ); + } + _render = (props: NavigationTransitionProps, prevProps: NavigationTransitionProps): React.ReactElement => { + return ( + + ); + } + _configureTransition = ( + _transitionProps: NavigationTransitionProps, + _prevTransitionProps: NavigationTransitionProps + ) => { + return {}; + } +} + +/** + * Header + */ +function renderHeaderBackButton(schema: string): JSX.Element { + switch (schema) { + case 'compact': + return ( + + ); + + default: + return ( + 'noop'} + pressColorAndroid="#ccc" + title="Press Me" + titleStyle={{ color: '#333' }} + tintColor="#2196f3" + truncatedTitle="Press" + width={85} + /> + ); + } +} + +const initAction: NavigationInitAction = NavigationActions.init({ + params: { + foo: "bar" + } +}); + +const navigateAction: NavigationNavigateAction = NavigationActions.navigate({ + routeName: "FooScreen", + params: { + foo: "bar" + }, + action: NavigationActions.navigate({ routeName: "BarScreen" }) +}); + +const resetAction: NavigationResetAction = NavigationActions.reset({ + index: 0, + key: "foo", + actions: [ + NavigationActions.navigate({ routeName: "FooScreen" }) + ] +}); + +const backAction: NavigationBackAction = NavigationActions.back({ + key: "foo" +}); + +const setParamsAction: NavigationSetParamsAction = NavigationActions.setParams({ + key: "foo", + params: { + foo: "bar" + } +}); + +const popAction: NavigationPopAction = NavigationActions.pop({ + n: 1, + immediate: true +}); + +const popToTopAction: NavigationPopToTopAction = NavigationActions.popToTop({ + key: "foo", + immediate: true +}); + +class Page1 extends React.Component { } + +const RootNavigator: NavigationContainer = createSwitchNavigator({ + default: { getScreen: () => Page1 }, +}); + +class Page2 extends React.Component { + navigatorRef: NavigationContainerComponent | null; + + componentDidMount() { + if (this.navigatorRef) { + this.navigatorRef.dispatch(NavigationActions.navigate({ routeName: 'default' })); + } + } + + render() { + return { this.navigatorRef = instance; }} />; + } +} diff --git a/types/react-navigation/v2/tsconfig.json b/types/react-navigation/v2/tsconfig.json new file mode 100644 index 0000000000..1b793c0613 --- /dev/null +++ b/types/react-navigation/v2/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../../", + "jsx": "react", + "typeRoots": [ + "../../" + ], + "paths": { + "react-navigation": [ + "react-navigation/v2" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-navigation-tests.tsx" + ] +} diff --git a/types/react-navigation/v2/tslint.json b/types/react-navigation/v2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-navigation/v2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 819852455128460171d4023922f24320255e074e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteus=20Hemstr=C3=B6m?= Date: Mon, 21 May 2018 12:16:03 +0200 Subject: [PATCH 027/236] [core-js] Change lpad/rpad to padStart/padEnd --- types/core-js/index.d.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/types/core-js/index.d.ts b/types/core-js/index.d.ts index 171aebc943..86259f05ba 100644 --- a/types/core-js/index.d.ts +++ b/types/core-js/index.d.ts @@ -755,8 +755,8 @@ declare namespace core { raw(template: TemplateStringsArray, ...substitutions: any[]): string; startsWith(text: string, searchString: string, position?: number): boolean; at(text: string, index: number): string; - lpad(text: string, length: number, fillStr?: string): string; - rpad(text: string, length: number, fillStr?: string): string; + padStart(text: string, length: number, fillStr?: string): string; + padEnd(text: string, length: number, fillStr?: string): string; escapeHTML(text: string): string; unescapeHTML(text: string): string; }; @@ -1454,9 +1454,13 @@ declare module "core-js/fn/string/includes" { const includes: typeof core.String.includes; export = includes; } -declare module "core-js/fn/string/lpad" { - const lpad: typeof core.String.lpad; - export = lpad; +declare module "core-js/fn/string/pad-end" { + const padEnd: typeof core.String.padEnd; + export = padEnd; +} +declare module "core-js/fn/string/pad-start" { + const padStart: typeof core.String.padStart; + export = padStart; } declare module "core-js/fn/string/raw" { const raw: typeof core.String.raw; @@ -1466,10 +1470,6 @@ declare module "core-js/fn/string/repeat" { const repeat: typeof core.String.repeat; export = repeat; } -declare module "core-js/fn/string/rpad" { - const rpad: typeof core.String.rpad; - export = rpad; -} declare module "core-js/fn/string/starts-with" { const startsWith: typeof core.String.startsWith; export = startsWith; @@ -2273,9 +2273,13 @@ declare module "core-js/library/fn/string/includes" { const includes: typeof core.String.includes; export = includes; } -declare module "core-js/library/fn/string/lpad" { - const lpad: typeof core.String.lpad; - export = lpad; +declare module "core-js/library/fn/string/pad-end" { + const padEnd: typeof core.String.padEnd; + export = padEnd; +} +declare module "core-js/library/fn/string/pad-start" { + const padStart: typeof core.String.padStart; + export = padStart; } declare module "core-js/library/fn/string/raw" { const raw: typeof core.String.raw; @@ -2285,10 +2289,6 @@ declare module "core-js/library/fn/string/repeat" { const repeat: typeof core.String.repeat; export = repeat; } -declare module "core-js/library/fn/string/rpad" { - const rpad: typeof core.String.rpad; - export = rpad; -} declare module "core-js/library/fn/string/starts-with" { const startsWith: typeof core.String.startsWith; export = startsWith; From abf06b4f43e53c90e71e2abed2d3f5dcbb69d82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Magrin?= Date: Mon, 21 May 2018 12:32:59 +0200 Subject: [PATCH 028/236] Try to fix dependencies --- types/react-navigation/v2/tsconfig.json | 5 ++++- types/react-router-navigation-core/tsconfig.json | 10 +++++++++- types/react-router-navigation/tsconfig.json | 10 +++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/types/react-navigation/v2/tsconfig.json b/types/react-navigation/v2/tsconfig.json index 1b793c0613..1afd5d30f6 100644 --- a/types/react-navigation/v2/tsconfig.json +++ b/types/react-navigation/v2/tsconfig.json @@ -14,12 +14,15 @@ "typeRoots": [ "../../" ], + "types": [], "paths": { "react-navigation": [ "react-navigation/v2" + ], + "react-navigation/*": [ + "react-navigation/v2/*" ] }, - "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/react-router-navigation-core/tsconfig.json b/types/react-router-navigation-core/tsconfig.json index b356b2d5c5..b773967cc9 100644 --- a/types/react-router-navigation-core/tsconfig.json +++ b/types/react-router-navigation-core/tsconfig.json @@ -5,6 +5,14 @@ "../" ], "types": [], + "paths": { + "react-navigation": [ + "react-navigation/v2" + ], + "react-navigation/*": [ + "react-navigation/v2/*" + ] + }, "module": "commonjs", "lib": [ "es6", @@ -22,4 +30,4 @@ "index.d.ts", "react-router-navigation-core-tests.tsx" ] -} \ No newline at end of file +} diff --git a/types/react-router-navigation/tsconfig.json b/types/react-router-navigation/tsconfig.json index e10c25a443..c55f423c19 100644 --- a/types/react-router-navigation/tsconfig.json +++ b/types/react-router-navigation/tsconfig.json @@ -5,6 +5,14 @@ "../" ], "types": [], + "paths": { + "react-navigation": [ + "react-navigation/v2" + ], + "react-navigation/*": [ + "react-navigation/v2/*" + ] + }, "module": "commonjs", "lib": [ "es6", @@ -22,4 +30,4 @@ "index.d.ts", "react-router-navigation-tests.tsx" ] -} \ No newline at end of file +} From 55fabd3ae7b3e2dd548d02d4c9a0818bdea5d593 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 21 May 2018 20:16:19 +0200 Subject: [PATCH 029/236] d3-interpolate : fix linting errors Switch to TypeScript 2.3 --- types/d3-interpolate/d3-interpolate-tests.ts | 2 +- types/d3-interpolate/index.d.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/types/d3-interpolate/d3-interpolate-tests.ts b/types/d3-interpolate/d3-interpolate-tests.ts index 50ade8008c..e77d3d4aef 100644 --- a/types/d3-interpolate/d3-interpolate-tests.ts +++ b/types/d3-interpolate/d3-interpolate-tests.ts @@ -232,7 +232,7 @@ iNum = d3Interpolate.interpolateBasisClosed([1, 50, 30, 10]); iString = d3Interpolate.piecewise(d3Interpolate.interpolateRgb.gamma(2.2), ['red', 'green', 'blue']); iString = d3Interpolate.piecewise(d3Interpolate.interpolateCubehelix, ['red', 'green', 'blue']); -iZoom = d3Interpolate.piecewise(d3Interpolate.interpolateZoom, [[50, 50, 300], [100, 100, 500]] as d3Interpolate.ZoomView[]); +iZoom = d3Interpolate.piecewise(d3Interpolate.interpolateZoom, [[50, 50, 300], [100, 100, 500]]); iNum = d3Interpolate.piecewise(d3Interpolate.interpolateNumber, [1, 2, 3]); iNum = d3Interpolate.piecewise(d3Interpolate.interpolateRound, [1.1, 2.2, 3.3]); iString = d3Interpolate.piecewise(d3Interpolate.interpolateString, ['a', 'b', 'c']); diff --git a/types/d3-interpolate/index.d.ts b/types/d3-interpolate/index.d.ts index 4d6d67f5d5..3853bff326 100644 --- a/types/d3-interpolate/index.d.ts +++ b/types/d3-interpolate/index.d.ts @@ -1,9 +1,10 @@ -// Type definitions for D3JS d3-interpolate module 1.1 +// Type definitions for D3JS d3-interpolate module 1.2 // Project: https://github.com/d3/d3-interpolate/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -// Last module patch version validated against: 1.1.1 +// Last module patch version validated against: 1.2.0 import { ColorCommonInstance } from 'd3-color'; From c3b80513fd56b0c4bdf075bf0674289ef6a6860d Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 21 May 2018 20:22:41 +0200 Subject: [PATCH 030/236] Typescript version for d3-scale, required for d3-interpoalte --- types/d3-scale/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/d3-scale/index.d.ts b/types/d3-scale/index.d.ts index b3ca4114e2..9471096fb9 100644 --- a/types/d3-scale/index.d.ts +++ b/types/d3-scale/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/d3/d3-scale/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 // Last module patch version validated against: 2.0.0 From 7526c00cc01a1e84dfb30e0e97d7dc4725b25e90 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 21 May 2018 20:44:39 +0200 Subject: [PATCH 031/236] Typescript version for d3-array, required for d3-interpoalte --- types/d3-array/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/d3-array/index.d.ts b/types/d3-array/index.d.ts index 67cd291f22..a42f8e1fe9 100644 --- a/types/d3-array/index.d.ts +++ b/types/d3-array/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/d3/d3-array // Definitions by: Alex Ford , Boris Yankov , Tom Wanzek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 // Last module patch version validated against: 1.2.0 From 09f426148f2bdd052de40d224b4ea207054d1cf5 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 21 May 2018 20:46:23 +0200 Subject: [PATCH 032/236] d3-interpolate : removed TS2.3 constraint --- types/d3-array/index.d.ts | 1 - types/d3-interpolate/index.d.ts | 3 +-- types/d3-scale/index.d.ts | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/types/d3-array/index.d.ts b/types/d3-array/index.d.ts index a42f8e1fe9..67cd291f22 100644 --- a/types/d3-array/index.d.ts +++ b/types/d3-array/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/d3/d3-array // Definitions by: Alex Ford , Boris Yankov , Tom Wanzek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 // Last module patch version validated against: 1.2.0 diff --git a/types/d3-interpolate/index.d.ts b/types/d3-interpolate/index.d.ts index 3853bff326..ceab2db551 100644 --- a/types/d3-interpolate/index.d.ts +++ b/types/d3-interpolate/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/d3/d3-interpolate/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 // Last module patch version validated against: 1.2.0 @@ -56,7 +55,7 @@ export function interpolateString(a: string | { toString(): string }, b: string export function interpolateDate(a: Date, b: Date): ((t: number) => Date); -type ArrayInterpolator = ((t: number) => A); +type ArrayInterpolator = ((t: number) => A); export function interpolateArray(a: any[], b: A): ArrayInterpolator; diff --git a/types/d3-scale/index.d.ts b/types/d3-scale/index.d.ts index 9471096fb9..b3ca4114e2 100644 --- a/types/d3-scale/index.d.ts +++ b/types/d3-scale/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/d3/d3-scale/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 // Last module patch version validated against: 2.0.0 From 1e824708e8f2a46cd231d8346bcac9cdd36b1d68 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 21 May 2018 20:57:27 +0200 Subject: [PATCH 033/236] d3-interpolate : exported type Added rule to tslint --- types/d3-interpolate/index.d.ts | 2 +- types/d3-interpolate/tslint.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/d3-interpolate/index.d.ts b/types/d3-interpolate/index.d.ts index ceab2db551..7d8ee60252 100644 --- a/types/d3-interpolate/index.d.ts +++ b/types/d3-interpolate/index.d.ts @@ -55,7 +55,7 @@ export function interpolateString(a: string | { toString(): string }, b: string export function interpolateDate(a: Date, b: Date): ((t: number) => Date); -type ArrayInterpolator = ((t: number) => A); +export type ArrayInterpolator = ((t: number) => A); export function interpolateArray(a: any[], b: A): ArrayInterpolator; diff --git a/types/d3-interpolate/tslint.json b/types/d3-interpolate/tslint.json index 604d5950cf..9846c79a4d 100644 --- a/types/d3-interpolate/tslint.json +++ b/types/d3-interpolate/tslint.json @@ -2,6 +2,7 @@ "extends": "dtslint/dt.json", "rules": { "unified-signatures": false, - "callable-types": false + "callable-types": false, + "no-unnecessary-generics": false } } From 4ee2a16c775c7ba0d69ce919ac968749bd0e57b5 Mon Sep 17 00:00:00 2001 From: stuartlo Date: Mon, 21 May 2018 17:56:18 -0700 Subject: [PATCH 034/236] Update typings to CKEditor v4.9.2 --- types/ckeditor/ckeditor-tests.ts | 12 +- types/ckeditor/index.d.ts | 3510 ++++++++++++++++++------------ 2 files changed, 2172 insertions(+), 1350 deletions(-) diff --git a/types/ckeditor/ckeditor-tests.ts b/types/ckeditor/ckeditor-tests.ts index 1a906bc26e..21288c1f93 100644 --- a/types/ckeditor/ckeditor-tests.ts +++ b/types/ckeditor/ckeditor-tests.ts @@ -6,9 +6,9 @@ function test_CKEDITOR() { CKEDITOR.skinName = 'moono'; CKEDITOR.skinName = 'myskin,/customstuff/myskin/'; var editor = new CKEDITOR.editor(); - if (editor.getSelection().getType() == CKEDITOR.SELECTION_ELEMENT) - if (editor.getSelection().getType() == CKEDITOR.SELECTION_NONE) - if (editor.getSelection().getType() == CKEDITOR.SELECTION_TEXT) + if (editor.getSelection(true).getType() == CKEDITOR.SELECTION_ELEMENT) + if (editor.getSelection(false).getType() == CKEDITOR.SELECTION_NONE) + if (editor.getSelection(true).getType() == CKEDITOR.SELECTION_TEXT) alert(CKEDITOR.basePath); if (CKEDITOR.currentInstance) alert(CKEDITOR.currentInstance.name); @@ -268,11 +268,11 @@ function test_dom_range() { alert(range.collapsed); range.selectNodeContents(range.document.getBody()); range.selectNodeContents(editor.document.getBody()); - alert(range.endContainer.getName()); + alert(range.endContainer.getPrivate()); range.selectNodeContents(editor.document.getBody()); alert(range.endOffset); range.selectNodeContents(editor.document.getBody()); - alert(range.startContainer.getName()); + alert(range.startContainer.getDocument()); range.selectNodeContents(editor.document.getBody()); alert(range.startOffset); } @@ -558,7 +558,7 @@ function test_selection() { var editor = new CKEDITOR.editor(); var testNode = CKEDITOR.document.getById('myElement'); - var selection = editor.getSelection(); + var selection = editor.getSelection(true); var ranges = selection.getRanges(); for (var i = 0, c = ranges.length; i < c; i++) { var range = ranges[i]; diff --git a/types/ckeditor/index.d.ts b/types/ckeditor/index.d.ts index 3370479bff..b6cef62744 100644 --- a/types/ckeditor/index.d.ts +++ b/types/ckeditor/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for CKEditor -// Project: http://ckeditor.com/ +// Type definitions for CKEditor 4.9.2 +// Project: https://ckeditor.com/ckeditor-4/ // Definitions by: Thomas Wittwer +// Stuart Long // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // WORK-IN-PROGRESS: Any contribution support welcomed. @@ -13,101 +14,120 @@ declare namespace CKEDITOR { // Config options var disableAutoInline: boolean; - var disableObjectResizing: boolean; var replaceClass: string; var skinName: string; // Properties - var ALT: number; - var CTRL: number; - var DIALOG_RESIZE_BOTH: number; - var DIALOG_RESIZE_HEIGHT: number; - var DIALOG_RESIZE_NONE: number; - var DIALOG_RESIZE_WIDTH: number; - var DIALOG_STATE_IDLE: number; - var DIALOG_STATE_BUSY: number; - var ELEMENT_MODE_APPENDTO: number; - var ELEMENT_MODE_INLINE: number; - var ELEMENT_MODE_NONE: number; - var ELEMENT_MODE_REPLACE: number; - var END: number; - var ENTER_BR: number; - var ENTER_P: number; - var EVENT_PHASE_AT_TARGET: number; - var EVENT_PHASE_BUBBLING: number; - var EVENT_PHASE_CAPTURING: number; - var LINEUTILS_AFTER: number; - var LINEUTILS_BEFORE: number; - var LINEUTIS_INSIDE: number; - var NODE_COMMENT: number; - var NODE_DOCUMENT: number; - var NODE_DOCUMENT_FRAGMENT: number; - var NODE_ELEMENT: number; - var NODE_TEXT: number; - var POSITION_BEFORE_START: number; - var POSITION_BEFORE_END: number; - var POSITION_AFTER_START: number; - var POSITION_AFTER_END: number; - var SELECTION_ELEMENT: number; - var SELECTION_NONE: number; - var SELECTION_TEXT: number; - var SHIFT: number; - var SHRINK_ELEMENT: number; - var SHRINK_TEXT: number; - var START: number; - var STYLE_BLOCK: string; - var STYLE_INLINE: string; - var STYLE_OBJECT: string; - var TRISTATE_DISABLED: number; - var TRISTATE_OFF: number; - var TRISTATE_ON: number; - var UI_BUTTON: string; - var UI_MENUBUTTON: string; - var UI_PANEL: string; - var UI_PANELBUTTON: string; - var UI_RICHCOMBO: string; - var UI_SEPARATOR: string; + const ALT: number; + const CTRL: number; + const DATA_TRANSFER_CROSS_EDITORS: number; + const DATA_TRANSFER_EXTERNAL: number; + const DATA_TRANSFER_INTERNAL: number; + const DIALOG_RESIZE_BOTH: number; + const DIALOG_RESIZE_HEIGHT: number; + const DIALOG_RESIZE_NONE: number; + const DIALOG_RESIZE_WIDTH: number; + const DIALOG_STATE_BUSY: number; + const DIALOG_STATE_IDLE: number; + const ELEMENT_MODE_APPENDTO: number; + const ELEMENT_MODE_INLINE: number; + const ELEMENT_MODE_NONE: number; + const ELEMENT_MODE_REPLACE: number; + const END: number; + const ENLARGE_BLOCK_CONTENTS: number; + const ENLARGE_ELEMENT: number; + const ENLARGE_INLINE: number; + const ENLARGE_LIST_ITEM_CONTENTS: number; + const ENTER_BR: number; + const ENTER_DIV: number; + const ENTER_P: number; + const EVENT_PHASE_AT_TARGET: number; + const EVENT_PHASE_BUBBLING: number; + const EVENT_PHASE_CAPTURING: number; + const FILTER_SKIP_TREE: number; + const LINEUTILS_AFTER: number; + const LINEUTILS_BEFORE: number; + const LINEUTIS_INSIDE: number; + const MOUSE_BUTTON_LEFT: number; + const MOUSE_BUTTON_MIDDLE: number; + const MOUSE_BUTTON_RIGHT: number; + const NODE_COMMENT: number; + const NODE_DOCUMENT: number; + const NODE_DOCUMENT_FRAGMENT: number; + const NODE_ELEMENT: number; + const NODE_TEXT: number; + const POSITION_AFTER_END: number; + const POSITION_AFTER_START: number; + const POSITION_BEFORE_END: number; + const POSITION_BEFORE_START: number; + const POSITION_CONTAINS: number; + const POSITION_DISCONNECTED: number; + const POSITION_FOLLOWING: number; + const POSITION_IDENTICAL: number; + const POSITION_IS_CONTAINED: number; + const POSITION_PRECEDING: number; + const SELECTION_ELEMENT: number; + const SELECTION_NONE: number; + const SELECTION_TEXT: number; + const SHIFT: number; + const SHRINK_ELEMENT: number; + const SHRINK_TEXT: number; + const START: number; + const STYLE_BLOCK: string; + const STYLE_INLINE: string; + const STYLE_OBJECT: string; + const TRISTATE_DISABLED: number; + const TRISTATE_OFF: number; + const TRISTATE_ON: number; + const UI_BUTTON: string; + const UI_MENUBUTTON: string; + const UI_PANEL: string; + const UI_PANELBUTTON: string; + const UI_RICHCOMBO: string; + const UI_SEPARATOR: string; + const VERBOSITY_ERROR: number; + const VERBOSITY_WARN: number; + var basePath: string; var currentInstance: editor; var document: dom.document; - var env: environmentConfig; - var instances: { [id: string]: editor | undefined }; + var instances: { [id: string]: editor }; var loadFullCoreTimeout: number; var revision: string; var rnd: number; var status: string; var timestamp: string; + var verbosity: number; var version: string; - var config: config; + const config: config; // Methods function add(editor: editor): void; function addCss(css: string): void; function addTemplate(name: string, source: string): template; - function appendTo(element: string, config?: config, data?: string): editor; - function appendTo(element: HTMLElement, config?: config, data?: string): editor; + function appendTo(element: string | HTMLElement, config?: config, data?: string): editor; function domReady(): void; - function dialogCommand(dialogName: string): void; function editorConfig(config: config): void; + function error(errorCode: string, additionalData?: any): void; function getCss(): string; function getTemplate(name: string): template; function getUrl(resource: string): string; - function inline(element: string, instanceConfig?: config): editor; - function inline(element: HTMLElement, instanceConfig?: config): editor; + function inline(element: string | HTMLElement, instanceConfig?: config): editor; function inlineAll(): void; function loadFullCore(): void; function replace(element: string | HTMLTextAreaElement, config?: config): editor; function replaceAll(className?: string): void; function replaceAll(assertionFunction: (textarea: HTMLTextAreaElement, config: config) => boolean): void; + function warn(errorCode: string, additionalData?: any): void; // Event interface function capture(): void; - function define(name: string, meta: Object): void; - function fire(eventName: string, data?: Object, editor?: editor): any; - function fireOnce(eventName: string, data?: Object, editor?: editor): any; + function define(name: string, meta: { [key: string]: any }): void; + function fire(eventName: string, data?: { [key: string]: any }, editor?: editor): any; + function fireOnce(eventName: string, data?: { [key: string]: any }, editor?: editor): any; function hasListeners(eventName: string): boolean; - function on(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: Object, listenerData?: Object, priority?: number): void; - function once(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: Object, listenerData?: Object, priority?: number): void; + function on(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: { [key: string]: any }, listenerData?: { [key: string]: any }, priority?: number): void; + function once(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: { [key: string]: any }, listenerData?: { [key: string]: any }, priority?: number): void; function removeAllListeners(): void; function removeListener(eventName: string, listenerFunction: (eventInfo: eventInfo) => void): void; @@ -124,29 +144,31 @@ declare namespace CKEDITOR { collapsed: boolean; } - class comment { - - // Properties - type: number; - - // Methods - constructor(comment: string, ownerDocument?: document); - constructor(comment: Object, ownerDocument?: document); - getOuterHtml(): string; - + interface bookmark2 { + start: number[]; + end: number[]; + startOffset: number; + endOffset: number; + collapsed: boolean; + normalized: boolean; + is2: boolean; } + class comment extends node { + readonly type: number; + + constructor(comment: string | Node, ownerDocument?: document); + getOuterHtml(): string; + } class document extends domObject { + readonly $: Document; + readonly type: number; - // Properties - type: number; - - // Methods - constructor(domDocument: Object); + constructor(domDocument: { [key: string]: any }); appendStyleSheet(cssFileUrl: string): void; - appendStyleText(cssStyleText: string): Object; - createElement(name: string, attribsAndStyles?: { attributes: Object; styles: Object; }): element; + appendStyleText(cssStyleText: string): CSSStyleSheet; + createElement(name: string, attribsAndStyles?: { attributes: { [key: string]: any }; styles: { [key: string]: any }; }): element; createText(text: string): element; find(selector: string): nodeList; findOne(selector: string): element; @@ -161,61 +183,45 @@ declare namespace CKEDITOR { getSelection(): selection; getWindow(): window; write(html: string): void; - } + class documentFragment extends node { + readonly type: number; - class documentFragment { - - // Properties - type: number; - - // Methods - constructor(nodeOrDoc: Object); + constructor(nodeOrDoc: { [key: string]: any }); insertAfterNode(node: node): void; - } - class domObject extends event { + readonly $: any; - // Properties - $: HTMLElement; - - // Methods - constructor(nativeDomObject: Object); + constructor(nativeDomObject: { [key: string]: any }); clearCustomData(): void; equals(object: any): boolean; + fire(eventName: string, data?: any, editor?: editor): any; getCustomData(key: string): any; getPrivate(): any; getUniqueId(): number; removeAllListeners(): void; - removeCustomData(key: string): Object; - setCustomData(key: string, value: Object): domObject; - + removeCustomData(key: string): any; + setCustomData(key: string, value: any): domObject; } - class element extends node { + readonly $: HTMLElement; + readonly type: number; - // Properties - type: number; - - // Methods constructor(element: string, ownerDocument?: document); constructor(element: HTMLElement, ownerDocument?: document); addClass(className: string): void; - append(node: node, toStart?: boolean): node; - append(node: string, toStart?: boolean): node; + append(node: node | string, toStart?: boolean): node; appendBogus(force: boolean): void; appendHtml(html: string): void; appendText(text: string): node; breakParent(parent: element): void; contains(node: node): boolean; - copyAttributes(dest: element, skipAttributes: Object): void; - data(name: string): string; - data(name: string, value: string): void; - data(name: string, value: boolean): void; + copyAttributes(dest: element, skipAttributes: { [key: string]: string }): void; + data(name: string, value?: string | false): string; disableContextMenu(): void; find(selector: string): nodeList; findOne(selector: string): element; @@ -224,23 +230,22 @@ declare namespace CKEDITOR { focusPrevious(ignoreChildren?: boolean, indexToUse?: number): void; forEach(callback: (node: node) => void, type?: number, skipRoot?: boolean): void; getAttribute(name: string): string; - getBogus(): Object; - getChild(indices: number): node; - getChild(indices: number[]): node; + getBogus(): node | boolean; + getChild(indices: number | number[]): node; getChildCount(): number; getChildren(): nodeList; - getClientRect(): any; + getClientRect(): ClientRect; getComputedStyle(propertyName: string): string; getDirection(useComputed: boolean): string; getDocumentPosition(refDocument: document): position; - getDtd(): any; + getDtd(): dtdDefinition; getEditor(): editor; getElementsByTag(tagName: string): nodeList; - getFirst(evaluator?: Function): node; + getFirst(evaluator?: (node: node) => boolean): node; getFrameDocument(): document; getHtml(): string; getId(): string; - getLast(evaluator?: Function): node; + getLast(evaluator?: (node: node) => boolean): node; getName(): string; getNameAtt(): string; getOuterHtml(): string; @@ -257,7 +262,7 @@ declare namespace CKEDITOR { hide(): void; is(...name: string[]): boolean; is(name: any): boolean; - isBlockBoundary(customNodeNames: Object): boolean; + isBlockBoundary(customNodeNames: { [tagName: string]: 1 }): boolean; isEditable(textCursor?: boolean): boolean; isEmptyInlineRemoveable(): boolean; isIdentical(otherElement: element): boolean; @@ -273,205 +278,40 @@ declare namespace CKEDITOR { scrollIntoParent(parent: window, alignToTop: boolean, hscroll: boolean): void; scrollIntoView(alignToTop?: boolean): void; setAttribute(name: string, value: string): element; - setAttributes(attributesPairs: Object): element; + setAttributes(attributesPairs: { [key: string]: string }): element; setHtml(html: string): string; setOpacity(opacity: number): void; setSize(type: string, size: number, isBorderBox: boolean): void; - setState(state: number, base?: Object, useAria?: Object): void; + setState(state: number, base?: string, useAria?: boolean): void; setStyle(name: string, value: string): element; - setStyles(stylesPair: Object): element; + setStyles(stylesPair: { [key: string]: string }): element; setText(text: string): string; setValue(value: string): element; show(): void; unselectable(): void; //static method - static clearAllMarkers(database: Object): Object; - static clearMarkers(database: Object, element: Object, removeFromDatabase: Object): void; + static clearAllMarkers(database: any): any; + static clearMarkers(database: any, element: dom.element, removeFromDatabase: boolean): void; static createFromHtml(html: string): element; - static get(element: string): element; - static get(element: any): element; - static setMarker(database: Object, element: Object, name: Object, value: Object): domObject; - + static get(element: string | HTMLElement | element): element; + static setMarker(database: any, element: dom.element, name: string, value: any): dom.element; } - class elementPath { - constructor(startNode: element, root: element); - constructor(startNode: element); - block: element; - blockLimit: element; - root: element; - elements: element[]; + readonly block: element; + readonly blockLimit: element; + readonly elements: element[]; + readonly lastElement: element; + readonly root: element; + + constructor(startNode: element, root?: element); compare(otherPath: elementPath): boolean; - contains(query: string, excludeRoot?: boolean, fromTop?: boolean): element; - contains(query: string[], excludeRoot?: boolean, fromTop?: boolean): element; - contains(query: (element: element) => boolean, excludeRoot?: boolean, fromTop?: boolean): element; - contains(query: Object, excludeRoot?: boolean, fromTop?: boolean): element; - contains(query: element, excludeRoot?: boolean, fromTop?: boolean): element; + contains(query: string | string[] | ((element: element) => boolean) | { [key: string]: any } | element, excludeRoot?: boolean, fromTop?: boolean): element; + direction(): 'ltr' | 'rtl'; isContextFor(tag: string): boolean; - direction(): string; } - - class range { - constructor(root: element); - constructor(root: document); - startContainer: any; - startOffset: number; - endContainer: any; - endOffset: number; - collapsed: boolean; - isDocRoot: boolean; - document: document; - root: element; - clone(): range; - collapse(toStart?: boolean): boolean; - cloneContents(): documentFragment; - deleteContents(mergeThen?: boolean): void; - extractContents(mergeThen?: boolean): documentFragment; - createBookmark(serializable?: boolean): bookmark; - createBookmark2(normalized?: boolean): Object; - createIterator(): iterator; - moveToBookmark(bookmark: Object): void; - getBoundaryNodes(): { startNode: node; endNode: node; }; - getCommonAncestor(includeSelf?: boolean, ignoreTextNode?: boolean): element; - optimize(): void; - optimizeBookmark(): void; - trim(ignoreStart?: boolean, ignoreEnd?: boolean): void; - enlarge(unit: number, excludeBrs?: boolean): void; - shrink(mode: number, selectContents: boolean): void; - insertNode(node: node): void; - moveToPosition(node: node, position: Object): void; - moveToRange(range: range): void; - selectNodeContents(node: node): void; - setStart(startNode: node, startOffset: number): void; - setEnd(endNode: node, endOffset: number): void; - setEndAfter(node: node): void; - setEndBefore(node: node): void; - setStartAfter(node: node): void; - setStartBefore(node: node): void; - setStartAt(node: node, position: number): void; - setEndAt(node: node, position: number): void; - fixBlock(isStart: boolean, blockTag: Object): Object; - select(): selection; - splitBlock(blockTag: Object): Object; - splitElement(toSplit: element): element; - removeEmptyBlocksAtEnd(atEnd: boolean): void; - startPath(): elementPath; - endPath(): elementPath; - checkBoundaryOfElement(element: element, checkType: number): boolean; - checkStartOfBlock(): boolean; - checkEndOfBlock(): boolean; - getPreviousNode(evaluator: Function, guard: Function, boundary: element): element; - getNextNode(evaluator: Function, guard: Function, boundary: element): element; - checkReadOnly(): boolean; - moveToElementEditablePosition(element: element, isMoveToEnd: boolean): boolean; - movetoClosestEditablePosition(element: element, isMoveToEnd: boolean): boolean; - moveToElementEditStart(target: Object): boolean; - moveToElementEditEnd(target: Object): boolean; - getEnclosedNode(): node; - getTouchedStartNode(): node; - getTouchedEndNode(): node; - getNextEditableNode(): Object; - getPreviousEditableNode(): Object; - scrollIntoView(): void; - } - - - interface rangeListIterator { - - } - - class selection { - document: document; - isFake: boolean; - isLocked: boolean; - rev: number; - root: element; - constructor(target: document); - constructor(target: element); - constructor(target: selection); - createBookmarks(serializable: Object): bookmark[]; - createBookmarks2(normalized: Object): Object[]; - fake(element: element): void; - getCommonAncestor(): element; - getNative(): Object; - getRanges(onlyEditables?: boolean): any[]; - getSelectedElement(): element; - getSelectedText(): string; - getStartElement(): element; - getType(): number; - isHidden(): boolean; - lock(): void; - removeAllRanges(): void; - reset(): void; - scrollIntoView(): void; - selectBookmarks(bookmarks: any[]): selection; - selectElement(element: element): void; - selectRanges(ranges: any[]): void; - unlock(restore: Object): void; - } - - - class rangeList { - constructor(ranges: range[]); - constructor(range: range); - createIterator(): rangeListIterator; - createBokmarks(serializable?: boolean): bookmark[]; - createBookmarks2(normalized?: boolean): Object[]; - moveToBookmark(bookmarks: Object[]): void; - } - - - class iterator { - constructor(range: range); - getNextParagraph(blockTag?: string): element; - activeFilter: filter; - enforceRealBlocks: boolean; - enlargeBr: boolean; - filter: filter; - } - - - class node extends domObject { - constructor(domNode: Node); - appendTo(element: element): element; - clone(includeChildren: boolean, cloneId: boolean): node; - hasPrevious(): boolean; - hasNext(): boolean; - insertAfter(node: node): node; - insertBefore(node: node): node; - insertBeforeMe(node: node): node; - getAddress(normalized?: boolean): Object[]; - getDocument(): document; - getIndex(normalized?: boolean): number; - getNextSourceNode(startFromSibling: Object, nodeType: Object, guard: Object): void; - getPreviousSourceNode(startFromSibling: Object, nodeType: Object, guard: Object): void; - getPrevious(evaluator?: Function): node; - getNext(evaluator?: Function): node; - getParent(allowFragmentParent?: boolean): element; - getParents(closerFirst?: boolean): node[]; - getCommonAncestor(node: Object): void; - getPosition(otherNode: Object): void; - getAscendant(reference: string, includeSelf?: boolean): node; - hasAscendant(name: Object, includeSelf: any): boolean; - remove(preserveChildren?: boolean): node; - replace(nodeToReplace: node): void; - trim(): void; - ltrim(): void; - rtrim(): void; - isReadOnly(): boolean; - } - - - class nodeList { - constructor(nativeList: Object); - count(): number; - getItem(index: number): node; - } - - class event { constructor(domEvent: Event); getKey(): number; @@ -481,89 +321,243 @@ declare namespace CKEDITOR { getTarget(): node; getPhase(): number; getPhaseOffset(): position; - on(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: Object, listenerData?: Object, priority?: number): Object; + on(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: any, listenerData?: any, priority?: number): { removeListener: () => void }; } + class iterator { + readonly activeFilter: filter; + enforceRealBlocks: boolean; + enlargeBr: boolean; + readonly filter: filter; + forceBrBreak: boolean; + readonly range: range; + constructor(range: range); + getNextParagraph(blockTag?: string): element; + } + + class node extends domObject { + constructor(domNode: Node); + appendTo(element: element): element; + clone(includeChildren: boolean, cloneId: boolean): node; + hasPrevious(): boolean; + hasNext(): boolean; + insertAfter(node: node): node; + insertBefore(node: node): node; + insertBeforeMe(node: node): node; + getAddress(normalized?: boolean): number[]; + getAscendant(reference: string, includeSelf?: boolean): node; + getCommonAncestor(node: node): void; + getDocument(): document; + getIndex(normalized?: boolean): number; + getNext(evaluator?: (node: node) => boolean): node; + getNextSourceNode(startFromSibling: boolean, nodeType: number, guard: node | ((node: node) => boolean)): void; + getParent(allowFragmentParent?: boolean): element; + getParents(closerFirst?: boolean): node[]; + getPosition(otherNode: node): void; + getPrevious(evaluator?: (node: node) => boolean): node; + getPreviousSourceNode(startFromSibling: boolean, nodeType: number, guard: node | ((node: node) => boolean)): void; + hasAscendant(name: string, includeSelf: boolean): boolean; + remove(preserveChildren?: boolean): node; + replace(nodeToReplace: node): void; + trim(): void; + ltrim(): void; + rtrim(): void; + isReadOnly(): boolean; + } + + class nodeList { + constructor(nativeList: NodeList); + count(): number; + getItem(index: number): node; + toArray(): node[]; + } + + class range { + readonly collapsed: boolean; + readonly document: document; + readonly endContainer: element | text; + readonly endOffset: number; + readonly root: element; + readonly startContainer: element | text; + readonly startOffset: number; + + constructor(root: element | document); + checkBoundaryOfElement(element: element, checkType: number): boolean; + checkEndOfBlock(): boolean; + checkReadOnly(): boolean; + checkStartOfBlock(): boolean; + clone(cloneId?: boolean): range; + cloneContents(): documentFragment; + collapse(toStart?: boolean): boolean; + createBookmark(serializable?: boolean): bookmark; + createBookmark2(normalized?: boolean): bookmark2; + createIterator(): iterator; + deleteContents(mergeThen?: boolean): void; + endPath(): elementPath; + enlarge(unit: number, excludeBrs?: boolean): void; + extractContents(mergeThen?: boolean, cloneId?: boolean): documentFragment; + fixBlock(isStart: boolean, blockTag: string): element; + getBoundaryNodes(): { startNode: node; endNode: node; }; + getCommonAncestor(includeSelf?: boolean, ignoreTextNode?: boolean): element; + getEnclosedNode(): node; + getNextEditableNode(): element | text; + getNextNode(evaluator: (element: dom.element) => boolean, guard?: (element: dom.element) => boolean, boundary?: element): element; + getPreviousEditableNode(): element | text; + getPreviousNode(evaluator: (element: dom.element) => boolean, guard?: (element: dom.element) => boolean, boundary?: element): element; + getTouchedEndNode(): node; + getTouchedStartNode(): node; + insertNode(node: node): void; + moveToBookmark(bookmark: bookmark | bookmark2): void; + moveToClosestEditablePosition(element?: element, isMoveForward?: boolean): boolean; + moveToElementEditEnd(target: element): boolean; + moveToElementEditStart(target: element): boolean; + moveToElementEditablePosition(element: element, isMoveToEnd: boolean): boolean; + moveToPosition(node: node, position: number): void; + moveToRange(range: range): void; + optimize(): void; + optimizeBookmark(): void; + removeEmptyBlocksAtEnd(atEnd: boolean): void; + scrollIntoView(): void; + select(): selection; + selectNodeContents(node: node): void; + setEnd(endNode: node, endOffset: number): void; + setEndAfter(node: node): void; + setEndAt(node: node, position: number): void; + setEndBefore(node: node): void; + setStart(startNode: node, startOffset: number): void; + setStartAfter(node: node): void; + setStartAt(node: node, position: number): void; + setStartBefore(node: node): void; + shrink(mode: number, selectContents?: boolean, options?: boolean | shrinkOptions): void; + splitBlock(cloneId?: boolean): void; + splitElement(toSplit: element, cloneId?: boolean): element; + startPath(): elementPath; + trim(ignoreStart?: boolean, ignoreEnd?: boolean): void; + + static mergeRanges(ranges: range[]): range[]; + } + + interface shrinkOptions { + shrinkOnBlockBoundary?: boolean, + skipBogus?: boolean + } + + class rangeList { + constructor(ranges?: range | range[]); + createBokmarks(serializable?: boolean): bookmark[]; + createBookmarks2(normalized?: boolean): bookmark2[]; + createIterator(): rangeListIterator; + moveToBookmarks(bookmarks: bookmark[]): void; + } + + + interface rangeListIterator { + getNextRange(mergeConsequent?: boolean): range; + } + + // see https://docs.com/ckeditor4/latest/api/CKEDITOR_dom_selection.html + class selection { + readonly FILLING_CHAR_SEQUENCE: string; + readonly document: document; + readonly isFake: boolean; + readonly isLocked: boolean; + readonly rev: number; + readonly root: element; + + constructor(target: document | element | selection); + createBookmarks(serializable: any): bookmark[]; + createBookmarks2(normalized: any): bookmark2[]; + fake(element: element, ariaLabel?: boolean): void; + getCommonAncestor(): element; + getNative(): Selection; + getRanges(onlyEditables?: boolean): range[]; + getSelectedElement(): element; + getSelectedText(): string; + getStartElement(): element; + getType(): number; + isCollapsed(): boolean; + isHidden(): boolean; + isInTable(allowPartialSelection?: boolean): boolean; + lock(): void; + removeAllRanges(): void; + reset(): void; + scrollIntoView(): void; + selectBookmarks(bookmarks: (bookmark | bookmark2)[]): selection; + selectElement(element: element): void; + selectRanges(ranges: range[]): void; + unlock(restore: boolean): void; + } + + class text extends node { + readonly $: Text; + readonly type: number; + + constructor(text: Text | string, ownerDocument?: document); + getLength(): number; + getText(): string; + setText(text: string): void; + split(offset: number): text; + substring(indexA: number, indexB?: number): void; + } + + class walker { + evaluator: (node: node) => boolean; + guard: (node: node) => boolean; + + static validEmptyBlockContainers: { [key: string]: any }; + + constructor(range: range); + checkBackward(): boolean; + checkForward(): boolean; + end(): void; + lastBackward(): node; + lastForward(): node; + next(): node; + previous(): node; + reset(): void; + + static blockBoundary(customNodeNames: any): (node: node) => boolean; + static bogus(isReject?: boolean): (node: node) => boolean; + static bookmark(contentOnly?: boolean, isReject?: boolean): (node: node) => boolean; + static editable(isReject?: boolean): (node: node) => boolean; + static empty(isReject?: boolean): (node: node) => boolean; + static ignored(isReject?: boolean): (node: node) => boolean; + static invisible(isReject?: boolean): (node: node) => boolean; + static listItemBoundary(): (node: node) => boolean; + static nodeType(type: number, isReject?: boolean): (node: node) => boolean; + static temp(isReject?: boolean): (node: node) => boolean; + static whitespaces(isReject?: boolean): (node: node) => boolean; + } interface position { x: number; y: number; } - interface widthAndHeight { width: number; height: number; } - - class text extends node { - constructor(text: Text, ownerDocument?: document); - constructor(text: string, ownerDocument?: document); - type: number; - getLength(): number; - getText(): string; - setText(text: string): void; - split(offset: number): text; - substring(indexA: number, indexB: number): void; - } - - class window extends domObject { - constructor(domWindow: Object); + constructor(domWindow: Window); focus(): void; getViewPaneSize(): widthAndHeight; getScrollPosition(): position; getFrame(): element; } - - - class walker { - constructor(range: range); - end(): void; - next(): node; - previous(): node; - checkForward(): boolean; - checkBackward(): boolean; - lastForward(): node; - lastBackward(): node; - reset(): void; - //static methods till the end - blockBoundary(customNodeNames: Object): Function; - listItemBoundary(): Function; - bookmark(contentOnly?: boolean, isReject?: boolean): Function; - whitespaces(isReject?: boolean): Function; - invisible(isReject?: boolean): Function; - nodeType(type: number, isReject?: boolean): Function; - bogus(isReject?: boolean): Function; - temp(isReject?: boolean): Function; - ignored(isReject?: boolean): Function; - editable(isReject?: boolean): Function; - } - } namespace ajax { - - // Methods - function load(url: string, callback?: Function): string; - function loadXml(url: string, callback?: Function): xml; - + function load(url: string, callback?: (data: any) => void): string; + function loadXml(url: string, callback?: (data: any) => void): xml; + function post(url: string, data: any, contentType?: string, callback?: (data: any) => void): void; } - interface xml { - - } - - - class command extends event { - - // Properties - contextSensitive: boolean; - editorFocus: boolean; - modes: any; + class command extends event implements commandDefinition { + fakeKeystroke: number; previousState: number; state: number; uiItems: any[]; @@ -573,53 +567,31 @@ declare namespace CKEDITOR { checkAllowed(noCache: boolean): boolean; disable(): void; enable(): void; - exec(data?: Object): boolean; + exec(data?: { [key: string]: any }): boolean; refresh(editor: editor, path: dom.elementPath): void; setState(newState: number): boolean; toggleState(): void; } - - class focusManager { - // Properties - currentActive: dom.domObject; - hasFocus: boolean; - - // Methods - constructor(editor: editor); - focus(currentActive?: dom.element): void; - lock(): void; - unlock(): void; - blur(noDelay?: boolean): void; - add(element: dom.element, isCapture: boolean): void; - remove(element: dom.element): void; + interface commandDefinition { + async?: boolean; + canUndo?: boolean; + context?: boolean; + contextSensitive?: boolean; + editorFocus?: boolean; + fakeKeystroke?: number; + modes?: { [key: string]: any }; + startDisabled?: boolean; + readOnly?: boolean; + exec(editor: editor, data?: any): boolean; + refresh?(editor: editor, path: dom.elementPath): void; } - interface keystrokeHandler { - - } - - interface toolbarGroups { - name?: string; - groups?: string[]; - } - - namespace config { - interface styleObject { - name?: string; - element: string; - attributes?: Object; - styles?: Object; - overrides?: Object; - } - } - - // Currently very incomplete. See here for all options that should be included: - // http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-fileTools_defaultFileName + // https://docs.com/ckeditor4/latest/api/CKEDITOR_config.html interface config { - allowedContent?: boolean | string | Object | CKEDITOR.style; - autoEmbed_widget?: string | Function; + allowedContent?: boolean | filter.allowedContentRules; + autoEmbed_widget?: string | ((url: string) => string); autoGrow_bottomSpace?: number; autoGrow_maxHeight?: number; autoGrow_minHeight?: number; @@ -634,10 +606,13 @@ declare namespace CKEDITOR { bodyId?: string; browserContextMenuOnCtrl?: boolean; - clipboard_defaultContentType?: string; // html | text + clipboard_defaultContentType?: 'html' | 'text'; clipboard_notificationDuration?: number; + cloudServices_tokenUrl?: string; + cloudServices_uploadUrl?: string; + codeSnippetGeshi_url?: string; codeSnippet_codeClass?: string; - codeSnippet_languages?: Object; + codeSnippet_languages?: { [key: string]: any }; coceSnippet_theme?: string; colorButton_backStyle?: config.styleObject; colorButton_colors?: string; @@ -649,6 +624,11 @@ declare namespace CKEDITOR { contentsCss?: string | string[]; contentsLangDirection?: string; contentsLanguage?: string; + copyFormatting_allowRules?: string; + copyFormatting_allowedContexts?: boolean | string[]; + copyFormatting_keystrokeCopy?: number; + copyFormatting_keystrokePaste?: number; + copyFormatting_outerCursor?: boolean; coreStyles_bold?: config.styleObject; coreStyles_italic?: config.styleObject; coreStyles_strike?: config.styleObject; @@ -660,7 +640,7 @@ declare namespace CKEDITOR { dataIndentationChars?: string; defaultLanguage?: string; devtools_styles?: string; - devtools_textCallback?: Function; + devtools_textCallback?: (editor: editor, dialog: dialog, element: dom.element, tabName: string) => string; dialog_backgroundCoverColor?: string; dialog_backgroundCoverOpacity?: number; dialog_buttonsOrder?: string; @@ -670,11 +650,15 @@ declare namespace CKEDITOR { disableNativeSpellChecker?: boolean; disableNativeTableHandles?: boolean; disableNativeObjectResizing?: boolean; - disableNativeReadonlySTyling?: boolean; - disallowedContent?: string | Object; // Documentation calls it CKEDITOR.filter.disallowedContentRules, but it is just a non-governed object or string. + disableNativeReadonlyStyling?: boolean; + disallowedContent?: filter.disallowedContentRules; div_wrapTable?: boolean; docType?: string; + easyimage_class?: string; + easyimage_defaultStyle?: string; + easyimage_styles?: { [key: string]: any }; + easyimage_toolbar?: string[] | string; emailProtection?: string; embed_provider?: string; enableTabKeyTools?: boolean; @@ -684,21 +668,23 @@ declare namespace CKEDITOR { entities_greek?: boolean; entities_latin?: boolean; entities_processNumerical?: boolean | string; - extraAllowedContent?: string | Object; + extraAllowedContent?: filter.allowedContentRules; extraPlugins?: string; fileTools_defaultFileName?: string; + fileTools_requestHeaders?: { [key: string]: any }; filebrowserBrowseUrl?: string; filebrowserFlashBrowseUrl?: string; filebrowserFlashUploadUrl?: string; filebrowserImageBrowseLinkUrl?: string; filebrowserImageBrowseUrl?: string; filebrowserImageUploadUrl?: string; + filebrowserUploadMethod?: string; filebrowserUploadUrl?: string; filebrowserWindowFeatures?: string; filebrowserWindowHeight?: number | string; filebrowserWindowWidth?: number | string; - fillEmptyBlocks?: boolean | Function; + fillEmptyBlocks?: boolean | ((element: htmlParser.element) => boolean); find_highlight?: config.styleObject; flashAddEmbedTag?: boolean; flashConvertOnEdit?: boolean; @@ -737,6 +723,7 @@ declare namespace CKEDITOR { ignoreEmptyParagraph?: boolean; image2_alignClasses?: string[]; + image2_altRequired?: boolean; image2_captionedClass?: string; image2_disableResizer?: boolean; image2_prefillDimensions?: boolean; @@ -751,7 +738,7 @@ declare namespace CKEDITOR { jqueryOverrideVal?: boolean; justifyClasses?: string[]; - keystrokes?: any[]; // Number, string pair really... silly structure... they should fix this. + keystrokes?: [number, string][]; language?: string; language_list?: string[]; @@ -766,9 +753,10 @@ declare namespace CKEDITOR { magicline_keystrokePrevious?: number; magicline_tabuList?: string[]; magicline_triggerOffset?: number; + mathJaxClass?: string; mathJaxLib?: string; menu_groups?: string; - menu_subMenuDelay?: string; + menu_subMenuDelay?: number; newpage_html?: string; notification_duration?: number; @@ -781,6 +769,8 @@ declare namespace CKEDITOR { pasteFromWordPromptCleanup?: boolean; pasteFromWordRemoveFontStyles?: boolean; pasteFromWorkRemoveStyles?: boolean; + pasteFromWord_heuristicsEdgeList?: boolean; + pasteFromWord_inlineImages?: boolean; plugins?: string; protectedSource?: RegExp[]; @@ -815,7 +805,7 @@ declare namespace CKEDITOR { scayt_minWordLength?: number; scayt_moreSuggestions?: string; scayt_multiLanguageMode?: boolean; - scayt_multiLanguageStyles?: Object; + scayt_multiLanguageStyles?: { [key: string]: any }; scayt_sLang?: string; scayt_serviceHost?: string; scayt_servicePath?: string; @@ -825,7 +815,7 @@ declare namespace CKEDITOR { scayt_uiTabs?: string; scayt_userDictionaryName?: string; - sharedSpaces?: CKEDITOR.sharedSpace; + sharedSpaces?: sharedSpace; shiftEnterMode?: number; skin?: string; smiley_columns?: number; @@ -833,8 +823,8 @@ declare namespace CKEDITOR { smiley_images?: string[]; smiley_path?: string; sourceAreaTabSize?: number; - specialChars?: any[]; // Seems to be an array of a string, or a two-element string-array - startupFocus?: boolean; + specialChars?: (string | [string, string])[]; + startupFocus?: string | boolean; startupMode?: string; startupOutlineBlocks?: boolean; startupShowBorders?: boolean; @@ -845,7 +835,7 @@ declare namespace CKEDITOR { tabIndex?: number; tabSpaces?: number; templates?: string; - templates_files?: Object; + templates_files?: { [key: string]: any }; templates_replaceContent?: boolean; title?: string | boolean; toolbar?: string | (string | string[] | { name: string, items?: string[], groups?: string[] })[] | null; @@ -865,527 +855,197 @@ declare namespace CKEDITOR { wsc_customDictionaryIds?: string; wsc_customLoaderScript?: string; wsc_customerId?: string; + wsc_height?: string; wsc_lang?: string; + wsc_left?: string; + wsc_top?: string; wsc_userDictionaryName?: string; + wsc_width?: string; } - - interface feature { - - } - - - interface sharedSpace { - top?: string | HTMLElement; - bottom?: string | HTMLElement; - } - - module skin { - var icons: { [name: string]: { path: string } }; - function addIcon(name: string, path: string, offset?: number, bgsize?: string): void; - } - - class style { - constructor(something: { element: string, attributes: { [att: string]: string } }); - applyToRange(range: Range, editor: editor): void; - } - - class editable extends dom.element { - constructor(editor: editor, element: HTMLElement | dom.element); - hasFocus: boolean; - attachListener(obj: event | editable, eventName: string, listenerFunction: (ei: eventInfo) => void, - scopeobj?: {}, listenerData?: any, priority?: number): listenerRegistration; - } - - - class menu { - constructor(); - add(item: any): void; - addListener(listenerFn: (startElement: dom.element, selection: dom.selection, path: dom.elementPath) => any): void; - hide(returnFocus?: boolean): void; - removeAll(): void; - show(offsetParent: dom.element, corner?: number, offsetX?: number, offsetY?: number): void; - } - - - namespace plugins { - - class contextMenu extends menu { - constructor(editor: editor); - addTarget(element: dom.element, nativeContextMenuOnCtrl?: boolean): void; - open(offsetParent: dom.element, corner?: number, offsetX?: number, offsetY?: number): void; - } - - - namespace link { - var emptyAnchorFix: boolean; - var fakeAnchor: boolean; - var synAnchorSelector: boolean; - function getEditorAnchors(editor: editor): dom.element[]; - function getSelectedLink(editor: editor): dom.elementPath; - function tryRestoreFakeAnchor(editor: editor, element: dom.element): dom.element; - } - - - namespace widget { - - namespace nestedEditable { - interface definition { - allowedContent?: any; - pathName?: string; - selector?: string; - } - } - - class nestedEditable extends CKEDITOR.dom.element { - editor: CKEDITOR.editor; - enterMode: number; - filter: CKEDITOR.filter; - shiftEnterMode: number; - - constructor(editor: CKEDITOR.editor, element: CKEDITOR.dom.element, config: { filter?: CKEDITOR.filter }); - getData(): string; - setData(data: string): void; - } - - - interface definition { - allowedContent?: any; - button?: string; - contentForms?: Object; - contentTransformations?: Object; - data?: Object | Function; - defaults?: Object; - dialog?: string; - downcast?: string | Function; - downcasts?: Object; - draggable?: boolean; - edit?: Function; - editables?: Object; - init?: Function; - inline?: boolean; - insert?: Function; - mask?: boolean; - name?: string; - parts?: Object; - pathName?: string; - requiredContent?: string | CKEDITOR.style; - styleToAllowedContentRules?: Function; - styleableElements?: string; - template?: string | CKEDITOR.template; - upcast?: string | Function; - upcastPriority?: number; - upcasts?: Object; - - toFeature?(): CKEDITOR.feature; - } - - class repository { - add(name: string, widgetDef: CKEDITOR.plugins.widget.definition): void; - addUpcastCallback(callback: Function): void; - capture(): void; - checkSelection(): void; - checkWidgets(options?: { initOnlyNew?: boolean; focusInited?: boolean }): void; - define(name: string, meta?: { errorProof?: boolean }): void; - del(widget: CKEDITOR.plugins.widget): void; - destroy(widget: CKEDITOR.plugins.widget, offline?: boolean): void; - destroyAll(offline?: boolean): void; - finalizeCreation(container: any): void; - focused: widget; - fire(eventName: string, data: Object, editor: editor): any; // should be boolean | Object - getByElement(element: any, checkWrapperOnly: boolean): CKEDITOR.plugins.widget; - hasListeners(eventName: string): boolean; - initOn(element: dom.element, widgetDef?: CKEDITOR.plugins.widget.definition, startupData?: Object): CKEDITOR.plugins.widget; - initOn(element: dom.element, widgetDef?: string, startupData?: Object): CKEDITOR.plugins.widget; - initOnAll(container?: dom.element): CKEDITOR.plugins.widget[]; - instances: { [id: string]: widget }; - on(eventName: string, listenerFunction: Function, scopeObj?: Object, listenerData?: Object, priority?: number): any; - once(): void; - parseElementClasses(classes: string): any; - removeAllListeners(eventName: string, listenerFunction: Function): void; - wrapElement(element: any, widgetName?: string): any; - } - } - - class widget implements CKEDITOR.plugins.widget.definition { - allowedContent: any; - button: string; - contentForms: any; - contentTransformations: any; - data: any; - dataReady: boolean; - defaults: any; - definition: CKEDITOR.plugins.widget.definition; - dialog: string; - downcast: string | Function; - downcasts: any; - draggable: boolean; - editables: any; - editor: CKEDITOR.editor; - element: CKEDITOR.dom.element; - focusedEditable: CKEDITOR.plugins.widget.nestedEditable - id: number; - init: Function; - inited: boolean; - inline: boolean; - insert: Function; - mask: boolean; - name: string; - parts: any; - pathName: string; - ready: boolean; - repository: CKEDITOR.plugins.widget.repository; - requiredContent: string | CKEDITOR.style; - styleToAllowedContentRules: Function; - styleableElements: string; - template: CKEDITOR.template; - upcast: string | Function; - upcastPriority: number; - upcasts: any; - wrapper: CKEDITOR.dom.element; - - constructor(widgetsRepo: CKEDITOR.plugins.widget.repository, id: number, element: CKEDITOR.dom.element, widgetDef: CKEDITOR.plugins.widget.definition, starupData?: Object); - - addClass(className: string): void; - applyStyle(style: CKEDITOR.style): void; - capture(): void; - checkStyleActive(style: CKEDITOR.style): boolean; - define(name: string, meta: { errorProof?: boolean }): void; - destroy(offline?: boolean): void; - destroyEditable(editableName: string, offline?: boolean): void; - edit(): boolean; - fire(eventName: string, data?: Object, editor?: CKEDITOR.editor): any; - fireOnce(eventName: string, data?: Object, editor?: CKEDITOR.editor): any; - focus(): void; - getClasses(): any; - hasClass(className: string, Whether: boolean): void; - hasListeners(eventName: string): boolean; - initEditable(editableName: string, definition: CKEDITOR.plugins.widget.nestedEditable.definition): boolean; - isInited(): boolean; - isReady(): boolean; - on(eventName: string, listenerFunction: Function, - scopeObj?: Object, listenerData?: Object, priority?: number): any; - once(): void; - removeAllListeners(): void; - removeClass(className: string): void; - removeListener(eventName: string, listenerFunction: Function): void; - removeStyle(style: CKEDITOR.style): void; - setData(keyOrData: string | Object, value: Object): CKEDITOR.plugins.widget; - setFocused(selected: boolean): CKEDITOR.plugins.widget; - setSelected(selected: boolean): CKEDITOR.plugins.widget; - toFeature(): CKEDITOR.feature; - updateDragHandlerPosition(): void; - } - - interface IPluginDefinition { - hidpi?: boolean; - lang?: string | string[]; - requires?: string | string[]; - afterInit?(editor: editor): any; - beforeInit?(editor: editor): any; - init?(editor: editor): void; - onLoad?(): any; - icons?: string; - } - - function add(name: string, definition: IPluginDefinition): void; - function add(name: string): void; - function addExternal(name: string, path: string, fileName?: string): void; - function get(name: string): any; - function getFilePath(name: string): string; - function getPath(name: string): string; - function load(name: string, callback: Function, scope?: Object): void; - function setLang(pluginName: string, languageCode: string, languageEntries: any): void; - var registered: {[key: string]: IPluginDefinition}; - } - - interface IMenuItemDefinition { - label:string, - command:string, - icon: string - group:string, - order:number - } - - class editor extends event { - activeEnterMode: number; - activeFilter: filter; - activeShiftEnterMode: number; - blockless: boolean; - config: config; - container: dom.element; - contextMenu: plugins.contextMenu; - dataProcessor: dataProcessor; - document: dom.document; - element: dom.element; - elementMode: number; - enterMode: number; - filter: filter; - focusManager: focusManager; - id: string; - keystrokeHandler: keystrokeHandler; - lang: any; - langCode: string; - mode: string; - name: string; - plugins: any; - readOnly: boolean; - shiftEnterMode: number; - status: string; - tabIndex: number; - templates: any; - title: any; - toolbar: any; - ui: ui; - widgets: plugins.widget.repository; - window: dom.window; - constructor(instanceConfig?: Object, element?: dom.element, mode?: number); - addCommand(commandName: string, commandDefinition: commandDefinition): void; - addFeature(feature: feature): boolean; - addMenuGroup(name: string, order?: number): void; - addMenuItem(name: string, definition?: IMenuItemDefinition): void; - addMenuItems(definitions: {[id:string]:IMenuItemDefinition}): void; - addMode(mode: string, exec: () => void): void; - addRemoveFormatFilter(func: Function): void; - applyStyle(style: style): void; - attachStyleStateChange(style: style, callback: Function): void; - checkDirty(): boolean; - commands:any; - createFakeElement(realElement: Object, className: Object, realElementType: Object, isResizable: Object): void; - createFakeParserElement(realElement: Object, className: Object, realElementType: Object, isResizable: Object): void; - createRange(): dom.range; - destroy(noUpdate?: boolean): void; - editable(): editable | null; - editable(elementOrEditable: dom.element): void; - editable(elementOrEditable: editable): void; - elementPath(startNode?: dom.node): dom.elementPath; - execCommand(commandName: string, data?: Object): boolean; - focus(): void; - forceNextSelectionCheck(): void; - getClipboardData(options: Object, callback: Function): void; - getColorFromDialog(callback: Function, scope?: Object): void; - getCommand(commandName: string): command; - getData(noEvents?: Object): string; - getMenuItem(name: string): Object; - getResizable(forContents: boolean): dom.element; - getSelectedHtml(toString?: false): dom.documentFragment; - getSelectedHtml(toString: true): string; - getSelectedHtml(toString?: boolean): CKEDITOR.dom.documentFragment | string; - getSelection(forceRealSelection?: boolean): dom.selection; - getSnapshot(): string; - getStylesSet(callback: Function): void; - getUiColor(): string; - insertElement(element: dom.element): void; - insertHtml(html: string, mode?: string): void; - insertText(text: string): void; - loadSnapshot(snapshot: Object): void; - lockSelection(sel?: dom.selection): boolean; - openDialog(dialogName: string, callback: Function): dialog; - popup(url: string, width?: number, height?: number, options?: string): void; - popup(url: string, width?: string, height?: number, options?: string): void; - popup(url: string, width?: number, height?: string, options?: string): void; - popup(url: string, width?: string, height?: string, options?: string): void; - removeMenuItem(name: string): void; - removeStyle(style: style): void; - resetDirty(): void; - resetUndo(): void; - resize(width: number, height: number, isContentHeight?: boolean, resizeInner?: boolean): void; - resize(width: string, height: number, isContentHeight?: boolean, resizeInner?: boolean): void; - resize(width: number, height: string, isContentHeight?: boolean, resizeInner?: boolean): void; - resize(width: string, height: string, isContentHeight?: boolean, resizeInner?: boolean): void; - restoreRealElement(fakeElement: Object): dom.element; - selectionChange(checkNow?: boolean): void; - setActiveEnterMode(enterMode: number, shiftEnterMode: number): void; - setActiveFilter(filter: filter): void; - setData(data: string, options?: { internal?: boolean; callback?: Function; noSnapshot?: boolean; }): void; - setKeystroke(keystroke: number, behavior?: string): void; - setKeystroke(keystroke: any[], behavior?: string): void; - setKeystroke(keystroke: number, behavior?: boolean): void; - setKeystroke(keystroke: any[], behavior?: boolean): void; - setMode(newMode: string, callback: Function): void; - setReadOnly(isReadOnly?: boolean): void; - setUiColor(color: string): void; - unlockSelection(restore?: boolean): void; - updateElement(): void; - } - - namespace editor { - interface eventObject { - activeEnterModeChange?: (evt: CKEDITOR.eventInfo) => void; - activeFilterChange?: (evt: CKEDITOR.eventInfo) => void; - afterCommandExec?: (evt: CKEDITOR.eventInfo) => void; - afterInsertHtml?: (evt: CKEDITOR.eventInfo) => void; - afterPaste?: (evt: CKEDITOR.eventInfo) => void; - afterPasteFromWord?: (evt: CKEDITOR.eventInfo) => void; - afterSetData?: (evt: CKEDITOR.eventInfo) => void; - afterUndoImage?: (evt: CKEDITOR.eventInfo) => void; - ariaEditorHelpLabel?: (evt: CKEDITOR.eventInfo) => void; - ariaWidget?: (evt: CKEDITOR.eventInfo) => void; - autogrow?: (evt: CKEDITOR.eventInfo) => void; - - beforeCommandExec?: (evt: CKEDITOR.eventInfo) => void; - beforeDestroy?: (evt: CKEDITOR.eventInfo) => void; - beforeGetData?: (evt: CKEDITOR.eventInfo) => void; - beforeModeUnload?: (evt: CKEDITOR.eventInfo) => void; - beforeSetMode?: (evt: CKEDITOR.eventInfo) => void; - beforeUndoImage?: (evt: CKEDITOR.eventInfo) => void; - blur?: (evt: CKEDITOR.eventInfo) => void; - - change?: (evt: CKEDITOR.eventInfo) => void; - configLoaded?: (evt: CKEDITOR.eventInfo) => void; - contentDirChanged?: (evt: CKEDITOR.eventInfo) => void; - contentDom?: (evt: CKEDITOR.eventInfo) => void; - contentDomInvalidated?: (evt: CKEDITOR.eventInfo) => void; - contentDomUnload?: (evt: CKEDITOR.eventInfo) => void; - customConfigLoaded?: (evt: CKEDITOR.eventInfo) => void; - - dataFiltered?: (evt: CKEDITOR.eventInfo) => void; - dataReady?: (evt: CKEDITOR.eventInfo) => void; - destroy?: (evt: CKEDITOR.eventInfo) => void; - dialogHide?: (evt: CKEDITOR.eventInfo) => void; - dialogShow?: (evt: CKEDITOR.eventInfo) => void; - dirChanged?: (evt: CKEDITOR.eventInfo) => void; - doubleclick?: (evt: CKEDITOR.eventInfo) => void; - dragend?: (evt: CKEDITOR.eventInfo) => void; - dragstart?: (evt: CKEDITOR.eventInfo) => void; - drop?: (evt: CKEDITOR.eventInfo) => void; - - elementsPathUpdate?: (evt: CKEDITOR.eventInfo) => void; - - fileUploadRequest?: (evt: CKEDITOR.eventInfo) => void; - fileUploadResponse?: (evt: CKEDITOR.eventInfo) => void; - floatingSpaceLayout?: (evt: CKEDITOR.eventInfo) => void; - focus?: (evt: CKEDITOR.eventInfo) => void; - - getData?: (evt: CKEDITOR.eventInfo) => void; - getSnapshot?: (evt: CKEDITOR.eventInfo) => void; - - insertElement?: (evt: CKEDITOR.eventInfo) => void; - insertHtml?: (evt: CKEDITOR.eventInfo) => void; - insertText?: (evt: CKEDITOR.eventInfo) => void; - instanceReady?: (evt: CKEDITOR.eventInfo) => void; - - key?: (evt: CKEDITOR.eventInfo) => void; - - langLoaded?: (evt: CKEDITOR.eventInfo) => void; - loadSnapshot?: (evt: CKEDITOR.eventInfo) => void; - loaded?: (evt: CKEDITOR.eventInfo) => void; - lockSnapshot?: (evt: CKEDITOR.eventInfo) => void; - maximize?: (evt: CKEDITOR.eventInfo) => void; - menuShow?: (evt: CKEDITOR.eventInfo) => void; - mode?: (evt: CKEDITOR.eventInfo) => void; - - notificationHide?: (evt: CKEDITOR.eventInfo) => void; - notificationShow?: (evt: CKEDITOR.eventInfo) => void; - notificationUpdate?: (evt: CKEDITOR.eventInfo) => void; - - paste?: (evt: CKEDITOR.eventInfo) => void; - pasteFromWord?: (evt: CKEDITOR.eventInfo) => void; - pluginsLoaded?: (evt: CKEDITOR.eventInfo) => void; - - readOnly?: (evt: CKEDITOR.eventInfo) => void; - removeFormatCleanup?: (evt: CKEDITOR.eventInfo) => void; - required?: (evt: CKEDITOR.eventInfo) => void; - resize?: (evt: CKEDITOR.eventInfo) => void; - - save?: (evt: CKEDITOR.eventInfo) => void; - saveSnapshot?: (evt: CKEDITOR.eventInfo) => void; - selectionChange?: (evt: CKEDITOR.eventInfo) => void; - setData?: (evt: CKEDITOR.eventInfo) => void; - stylesSet?: (evt: CKEDITOR.eventInfo) => void; - - template?: (evt: CKEDITOR.eventInfo) => void; - toDataFormat?: (evt: CKEDITOR.eventInfo) => void; - toHtml?: (evt: CKEDITOR.eventInfo) => void; - - unlockSnapshot?: (evt: CKEDITOR.eventInfo) => void; - updateSnapshot?: (evt: CKEDITOR.eventInfo) => void; - - widgetDefinition?: (evt: CKEDITOR.eventInfo) => void; - } - } - - interface eventInfo { - data: any; - editor: editor; - listenerData: any; - name: string; - sender: any; - cancel(): void; - removeListener(): void; - stop(): void; - } - - module filter { - interface allowedContentRules { - - } - } - - class filter { - allow(newRules: CKEDITOR.filter.allowedContentRules, featureName?: string, overrideCustom?: boolean): boolean; - - } - - interface buttonDefinition { - icon?: string; - iconOffset?: number; - label : string; - command : string; - toolbar : string; - } - - interface template { - - } - - interface dataProcessor { toDataFormat(html: string, fixForBody: string): void; toHtml(data: string, fixForBody?: string): void; } - class htmlDataProcessor { - dataFilter: htmlParser.filter; - htmlFilter: htmlParser.filter; - writer: htmlParser.basicWriter; + class dialog { + readonly state: number; - constructor(editor: editor); - toDataFormat(html: string, options?: Object): string; - toHtml(data: string, options?: Object): string; + constructor(editor: editor, dialogName: string); + + addFocusable(element: dom.element, index?: number): void; + addPage(contents: { [key: string]: any }): void; + click(id: string): any; + commitContent(): void; + diableButton(id: string): void; + enableButton(id: string): void; + foreach(fn: () => void): dialog; + getButton(id: string): ui.dialog.button; + getContentElement(pageId: string, elementId: string): ui.dialog.uiElement; + getElement(): dom.element; + getName(): string; + getPageCount(): number; + getParentEditor(): editor; + getPosition(): { [key: string]: any }; + getSelectedElement(): dom.element; + getSize(): { [key: string]: any }; + getValueOf(pageId: string, elementId: string): any; + hide(): void; + hidePage(id: string): void; + layout(): void; + move(x: number, y: number, save: boolean): void; + reset(): dialog; + resize(width: number, height: number): void; + selectPage(id: string): void; + setState(state: number): void; + setValueOf(pageId: string, elementId: string, value: any): void; + setupContent(): void; + show(): void; + showPage(id: string): void; + updateStyle(): void; + + static add(name: string, dialogDefinition: string | ((editor: editor) => dialog.IDialogDefinition)): void; + static addIframe(name: string, title: string, minWidth: number, minHeight: number, onContentLoad?: () => void, userDefinition?: { [key: string]: any }): void; + static addUIElement(typeName: string, builder: () => void): void; + static cancelButton(): void; + static exists(name: string | number): void; // NOTE: documentation says object, but it's an array accessor, so really a string or number will work + static getCurrent(): dialog; + static isTabEnabled(editor: editor, dialogName: string, tabName: string): boolean; + static okButton(): void; } + namespace dialog { - class event { - constructor(); - useCapture: boolean; - capture(): void; - define(name: string, meta: Object): void; - fire(eventName: string, data?: Object, editor?: editor): any; - fireOnce(eventName: string, data?: Object, editor?: editor): any; - hasListeners(eventName: string): boolean; - on(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: Object | null, listenerData?: Object | null, priority?: number): listenerRegistration; - once(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: Object | null, listenerData?: Object | null, priority?: number): listenerRegistration; - removeAllListeners(): void; - removeListener(eventName: string, listenerFunction: (eventInfo: eventInfo) => void): void; - static implementOn(targetObject: Object): void; + namespace definition { + + interface button extends uiElement { + disabled?: boolean; + } + + interface checkbox extends uiElement { + default?: string; + validate?: () => boolean; + } + + interface content { + accessKey?: string; + elements?: dialog.definition.uiElement[]; + id?: string; + label?: string; + title?: string; + } + + interface file extends labeledElement { + action?: string; + size?: string; + validate?: () => boolean; + } + + interface fileButton extends uiElement { + filebrowser?: string; + for?: string; + validate?: () => boolean; + } + + interface hbox extends uiElement { + children?: ui.dialog.uiElement[]; + height?: number; + padding?: number; + validate?: () => boolean; + widths?: number[]; + } + + interface html extends uiElement { + html?: string; + } + + interface labeledElement extends uiElement { + controlStyle?: string; + inputStyle?: string; + labelLayout?: string; + labelStyle?: string; + widths?: number[]; + } + + interface radio extends labeledElement { + default?: string; + items?: string[] | (string[])[]; + validate?: () => boolean; + } + + interface select extends labeledElement { + default?: string; + items?: string[] | (string[])[]; + multiple?: boolean; + size?: number; + validate?: () => boolean; + } + + interface textarea extends labeledElement { + bidi?: boolean; + cols?: number; + default?: string; + rows?: number; + validate?: () => boolean; + } + + interface textInput extends labeledElement { + bidi?: boolean; + default?: string; + maxLength?: number; + size?: number; + validate?: () => boolean; + } + + interface uiElement { + align?: string; + className?: string; + commit?: (widget: plugins.widget) => void; + id?: string; + label?: string; + onHide?: (elem: ui.dialog.uiElement) => void; + onLoad?: (elem: ui.dialog.uiElement) => void; + onShow?: (elem: ui.dialog.uiElement) => void; + requiredContent?: string | { [key: string]: any } | style; + setup?: (widget: plugins.widget) => void; + style?: string; + title?: string; + type?: string; + } + + interface vbox extends uiElement { + children?: ui.dialog.uiElement[]; + expand?: boolean; + heights?: number[]; + padding?: number; + styles?: string; + width?: number[]; + } + } + + interface IDialogDefinition { + buttons?: dialog.definition.button[]; + contents?: dialog.definition.content[]; + height?: number; + minHeight?: number; + minWidth?: number; + onCancel?: () => void; + onLoad?: () => void; + onOk?: () => void; + onShow?: () => void; + onHide?: () => void; + resizable?: number; + title?: string; + width?: number; + } } + class dialogCommand { + value: any; - interface commandDefinition { - async?: boolean; - canUndo?: boolean; - context?: boolean; - contextSensitive?: boolean; - editorFocus?: boolean; - modes?: Object; - startDisabled?: boolean; - exec(editor: editor, data?: Object): boolean; - readOnly?: boolean; - refresh?(editor: editor, path: dom.elementPath): void; + constructor(dialogName: string, ext?: { tabId?: string }); } - interface dtdDefinition { [outerTagName: string]: {[innerTagName: string]: 1}; $block: {[tagName: string]: 1}; @@ -1407,117 +1067,1429 @@ declare namespace CKEDITOR { } var dtd: dtdDefinition; + + class editable extends dom.element { + hasFocus: boolean; + readonly status: string; + constructor(editor: editor, element: HTMLElement | dom.element); + attachClass(className: string): void; + attachListener(obj: event | editable, eventName: string, listenerFunction: (ei: eventInfo) => void, scopeobj?: {}, listenerData?: any, priority?: number): listenerRegistration; + changeAttr(attr: string, val: string): void; + detach(): void; + insertElement(element: dom.element, range?: dom.range): void; + insertHtml(data: string, mode?: string, range?: dom.range): void; + insertText(text: dom.text): void; + isInline(): boolean; + setReadOnly(isReadOnly: boolean): void; + } + + class editor extends event { + readonly activeEnterMode: number; + readonly activeFilter: filter; + readonly activeShiftEnterMode: number; + readonly blockless: boolean; + readonly config: config; + readonly container: dom.element; + readonly contextMenu: plugins.contextMenu; + copyFormatting: plugins.copyformatting.state; + dataProcessor: dataProcessor; + readonly document: dom.document; + readonly element: dom.element; + readonly elementMode: number; + readonly enterMode: number; + readonly filter: filter; + readonly focusManager: focusManager; + readonly id: string; + readonly keystrokeHandler: keystrokeHandler; + readonly lang: any; + readonly langCode: string; + readonly mode: string; + readonly name: string; + readonly pasteFilter: filter; + readonly plugins: any; + readonly readOnly: boolean; + readonly shiftEnterMode: number; + readonly status: string; + readonly tabIndex: number; + readonly templates: any; + readonly title: any; + readonly toolbar: any; + readonly ui: ui; + readonly widgets: plugins.widget.repository; + readonly window: dom.window; + + constructor(instanceConfig?: config, element?: dom.element, mode?: number); + addCommand(commandName: string, commandDefinition: commandDefinition): void; + addContentsCss(cssPath: string): void; + addFeature(feature: feature): boolean; + addMenuGroup(name: string, order?: number): void; + addMenuItem(name: string, definition?: IMenuItemDefinition): void; + addMenuItems(definitions: { [id:string]: IMenuItemDefinition }): void; + addMode(mode: string, exec: () => void): void; + addRemoveFormatFilter(func: (element: dom.element) => boolean): void; + applyStyle(style: style): void; + attachStyleStateChange(style: style, callback: (state: number) => void): void; + checkDirty(): boolean; + createFakeElement(realElement: dom.element, className: string, realElementType: string, isResizable: boolean): void; + createFakeParserElement(realElement: dom.element, className: string, realElementType: string, isResizable: boolean): void; + createRange(): dom.range; + destroy(noUpdate?: boolean): void; + editable(elementOrEditable?: dom.element | editable): editable; + elementPath(startNode?: dom.node): dom.elementPath; + execCommand(commandName: string, data?: any): boolean; + extractSelectedHtml(toString?: boolean, removeEmptyBlock?: boolean): dom.documentFragment | string | void; + focus(): void; + forceNextSelectionCheck(): void; + getClipboardData(callbackOrOptions: { title: string } | ((data: any) => void), callback: (data: any) => void): void; + getColorFromDialog(callback: (color: string) => void, scope?: { [key: string]: any }): void; + getCommand(commandName: string): command; + getCommandKeystroke(command: command | string): number | null; + getData(internal: boolean): string; + getMenuItem(name: string): IMenuItemDefinition; + getResizable(forContents: boolean): dom.element; + getSelectedHtml(toString?: false): dom.documentFragment; + getSelectedHtml(toString: true): string; + getSelectedHtml(toString?: boolean): dom.documentFragment | string; + getSelection(forceRealSelection: boolean): dom.selection; + getSnapshot(): string; + getStylesSet(callback: (stylesDefinitions: style.definition[]) => void): void; + getUiColor(): string; + insertElement(element: dom.element): void; + insertHtml(html: string, mode?: string, range?: dom.range): void; + insertText(text: string): void; + loadSnapshot(snapshot: any): void; + lockSelection(sel?: dom.selection): boolean; + openDialog(dialogName: string, callback: () => void): dialog; + popup(url: string, width?: number | string, height?: number | string, options?: string): void; + removeMenuItem(name: string): void; + removeStyle(style: style): void; + resetDirty(): void; + resetUndo(): void; + resize(width: number | string, height: number | string, isContentHeight?: boolean, resizeInner?: boolean): void; + restoreRealElement(fakeElement: dom.element): dom.element; + selectionChange(checkNow?: boolean): void; + setActiveEnterMode(enterMode: number, shiftEnterMode: number): void; + setActiveFilter(filter: filter): void; + setData(data: string, options?: { internal?: boolean; callback?: () => void; noSnapshot?: boolean; }): void; + setKeystroke(keystroke: number, behavior: string | boolean): void; + setKeystroke(keystroke: [number, string | boolean][]): void; + setMode(newMode: string, callback: () => void): void; + setReadOnly(isReadOnly?: boolean): void; + setUiColor(color: string): void; + showNotification(message: string, type: plugins.notification.type, progressOrDuration: number): plugins.notification; + unlockSelection(restore?: boolean): void; + updateElement(): void; + } + + namespace editor { + interface eventObject { + activeEnterModeChange?: (evt: eventInfo) => void; + activeFilterChange?: (evt: eventInfo) => void; + afterCommandExec?: (evt: eventInfo) => void; + afterInsertHtml?: (evt: eventInfo) => void; + afterPaste?: (evt: eventInfo) => void; + afterPasteFromWord?: (evt: eventInfo) => void; + afterSetData?: (evt: eventInfo) => void; + afterUndoImage?: (evt: eventInfo) => void; + ariaEditorHelpLabel?: (evt: eventInfo) => void; + ariaWidget?: (evt: eventInfo) => void; + autogrow?: (evt: eventInfo) => void; + + beforeCommandExec?: (evt: eventInfo) => void; + beforeDestroy?: (evt: eventInfo) => void; + beforeGetData?: (evt: eventInfo) => void; + beforeModeUnload?: (evt: eventInfo) => void; + beforeSetMode?: (evt: eventInfo) => void; + beforeUndoImage?: (evt: eventInfo) => void; + blur?: (evt: eventInfo) => void; + + change?: (evt: eventInfo) => void; + configLoaded?: (evt: eventInfo) => void; + contentDirChanged?: (evt: eventInfo) => void; + contentDom?: (evt: eventInfo) => void; + contentDomInvalidated?: (evt: eventInfo) => void; + contentDomUnload?: (evt: eventInfo) => void; + customConfigLoaded?: (evt: eventInfo) => void; + + dataFiltered?: (evt: eventInfo) => void; + dataReady?: (evt: eventInfo) => void; + destroy?: (evt: eventInfo) => void; + dialogHide?: (evt: eventInfo) => void; + dialogShow?: (evt: eventInfo) => void; + dirChanged?: (evt: eventInfo) => void; + doubleclick?: (evt: eventInfo) => void; + dragend?: (evt: eventInfo) => void; + dragstart?: (evt: eventInfo) => void; + drop?: (evt: eventInfo) => void; + + elementsPathUpdate?: (evt: eventInfo) => void; + + fileUploadRequest?: (evt: eventInfo) => void; + fileUploadResponse?: (evt: eventInfo) => void; + floatingSpaceLayout?: (evt: eventInfo) => void; + focus?: (evt: eventInfo) => void; + + getData?: (evt: eventInfo) => void; + getSnapshot?: (evt: eventInfo) => void; + + insertElement?: (evt: eventInfo) => void; + insertHtml?: (evt: eventInfo) => void; + insertText?: (evt: eventInfo) => void; + instanceReady?: (evt: eventInfo) => void; + + key?: (evt: eventInfo) => void; + + langLoaded?: (evt: eventInfo) => void; + loadSnapshot?: (evt: eventInfo) => void; + loaded?: (evt: eventInfo) => void; + lockSnapshot?: (evt: eventInfo) => void; + maximize?: (evt: eventInfo) => void; + menuShow?: (evt: eventInfo) => void; + mode?: (evt: eventInfo) => void; + + notificationHide?: (evt: eventInfo) => void; + notificationShow?: (evt: eventInfo) => void; + notificationUpdate?: (evt: eventInfo) => void; + + paste?: (evt: eventInfo) => void; + pasteFromWord?: (evt: eventInfo) => void; + pluginsLoaded?: (evt: eventInfo) => void; + + readOnly?: (evt: eventInfo) => void; + removeFormatCleanup?: (evt: eventInfo) => void; + required?: (evt: eventInfo) => void; + resize?: (evt: eventInfo) => void; + + save?: (evt: eventInfo) => void; + saveSnapshot?: (evt: eventInfo) => void; + selectionChange?: (evt: eventInfo) => void; + setData?: (evt: eventInfo) => void; + stylesSet?: (evt: eventInfo) => void; + + template?: (evt: eventInfo) => void; + toDataFormat?: (evt: eventInfo) => void; + toHtml?: (evt: eventInfo) => void; + + unlockSnapshot?: (evt: eventInfo) => void; + updateSnapshot?: (evt: eventInfo) => void; + + widgetDefinition?: (evt: eventInfo) => void; + } + } + + namespace env { + var air: boolean; + var chrome: boolean; + var cssClass: string; + var edge: boolean; + var gecko: boolean; + var hc: boolean; + var hidpi: boolean; + var iOS: boolean; + var ie: boolean; + var isCompatible: boolean; + var mac: boolean; + var needsBrFiller: boolean; + var needsNbspFiller: boolean; + var quirks: boolean; + var safari: boolean; + var version: number; + var webkit: boolean; + + function secure(): boolean; + } + + class event { + static useCapture: boolean; + + constructor(); + capture(): void; + define(name: string, meta: { [key: string]: any }): void; + fire(eventName: string, data?: { [key: string]: any }, editor?: editor): any; + fireOnce(eventName: string, data?: { [key: string]: any }, editor?: editor): any; + hasListeners(eventName: string): boolean; + on(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: { [key: string]: any } | null, listenerData?: any, priority?: number): listenerRegistration; + once(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: { [key: string]: any } | null, listenerData?: any, priority?: number): listenerRegistration; + removeAllListeners(): void; + removeListener(eventName: string, listenerFunction: (eventInfo: eventInfo) => void): void; + + static implementOn(targetObject: { [key: string]: any }): void; + } + + interface eventInfo { + data: any; + editor: editor; + listenerData: any; + name: string; + sender: { [key: string]: any }; + + cancel(): void; + removeListener(): void; + stop(): void; + } + + interface feature { + allowedContent?: filter.allowedContentRules; + contentForms?: any; + contentTransformations?: any; + name?: string; + requiredContent?: string | style; + toFeature?: () => feature; + } + + namespace fileTools { + var isFileUploadSupported: boolean; + + function addUploadWidget(editor: editor, name: string, def: uploadWidgetDefinition): void; + function bindNotification(editor: editor, fileLoader: fileLoader): void; + function getUploadUrl(config: { [key: string]: any }, type?: string): string; + function isTypeSupported(file: Blob, supportedTypes: RegExp): boolean; + function markElement(element: dom.element, widgetName: string, loaderId: number): void; + + class fileLoader extends event { + readonly data: string; + readonly file: Blob; + readonly fileName: string; + readonly id: number; + readonly loaded: number; + readonly message: string; + readonly reader: FileReader; + readonly responseData: any; + status: string; + readonly total: number; + readonly uploadTotal: number; + readonly uploadUrl: string; + readonly uploaded: string; + readonly url: string; + readonly xhr: XMLHttpRequest; + + constructor(editor: editor, fileOrData: Blob | string, fileName?: string); + abort(): void; + isFinished(): boolean; + load(): void; + loadAndUpload(url: string, additionalRequestParameters?: any): void; + update(): void; + upload(url: string, additionalRequestParameters?: any): void; + } + + class uploadRepository extends event { + readonly loaders: fileLoader[]; + + constructor(editor: editor); + create(fileOrData: Blob | string, fileName: string, loaderType?: any): fileLoader; + isFinished(): boolean; + } + + interface uploadWidgetDefinition extends plugins.widget.definition { + additionalRequestParameters: any; + fileToElement: (pastedFile: any) => HTMLElement; + loadMethod: string; + loaderType: any; + onAbort: () => boolean; + onError: () => boolean; + onLoaded: () => boolean; + onUploaded: () => boolean; + onUploading: () => boolean; + replaceWith: () => any; + skipNotifications: boolean; + supportedTypes: string; + uploadUrl: string; + } + } + + module filter { + type allowedContentRule = string | style | { [key: string]: any}; + type allowedContentRules = allowedContentRule | allowedContentRule[]; + type contentRule = string | style; + type disallowedContentRules = string | { [key: string]: any}; + + interface transformation { + check?: string; + element?: string | style; + left?: (element: htmlParser.element | style) => boolean; + right: (element: htmlParser.element, tools: string | filter.transformationTools) => boolean; + } + + var transformationTools: transformationTools; + + interface transformationTools { + alignmentToAttribute(element: htmlParser.element): void; + alignmentToStyle(element: htmlParser.element): void; + lengthToAttribute(element: htmlParser.element, styleName: string, attrName?: string): void; + lengthToStyle(element: htmlParser.element, styleName: string, attrName?: string): void; + matchesTyle(element: htmlParser.element, style: style): void; + sizeToAttribute(element: htmlParser.element): void; + sizeToStyle(element: htmlParser.element): void; + splitBorderShorthand(element: htmlParser.element): void; + splitMarginShorthand(element: htmlParser.element): void; + transform(element: htmlParser.element, form: style | string): void; + } + } + + class filter { + readonly allowedContent: filter.allowedContentRules[]; + readonly customConfig: boolean; + readonly disabled: boolean; + readonly disallowedContent: any[]; + readonly editor: editor; + readonly elementCallbacks:((element: htmlParser.element) => number)[]; + readonly id: number; + + static instances: { [id: string]: filter }; + + constructor(editorOrRules: editor | filter.allowedContentRules); + addContentForms(forms: any[]): void; + addElementCallback(callback: (element: htmlParser.element) => number): void; + addFeature(feature: feature): boolean; + addTransformations(transformations: (string | filter.transformation)[][]): void; + allow(newRules: filter.allowedContentRules, featureName?: string, overrideCustom?: boolean): boolean; + applyTo(fragment: htmlParser.fragment | htmlParser.element, toHrml: boolean, transformOnly: boolean, enterMode: number): boolean; + check(test: filter.contentRule, applyTransformations?: boolean, strictCheck?: boolean): boolean; + checkFeature(feature: feature): boolean; + clone(): filter; + destroy(): void; + disable(): void; + disallow(newRules: filter.disallowedContentRules): void; + getAllowedEnterMode(defaultMode: number, reverse?: boolean): number; + } + + class focusManager { + currentActive: dom.domObject; + hasFocus: boolean; + + constructor(editor: editor); + add(element: dom.element, isCapture: boolean): void; + blur(noDelay?: boolean): void; + focus(currentActive?: dom.element): void; + lock(): void; + remove(element: dom.element): void; + unlock(): void; + } + + class htmlDataProcessor implements dataProcessor { + dataFilter: htmlParser.filter; + htmlFilter: htmlParser.filter; + writer: htmlParser.basicWriter; + + constructor(editor: editor); + toDataFormat(html: string, options?: string | { context?: string, filter?: filter, enterMode?: number }): string; + toHtml(data: string, options?: string | htmlDataProcessorOptions): string; + } + + interface htmlDataProcessorOptions { + context?: string; + fixForBody?: boolean; + filter?: filter; + dontFilter?: boolean; + enterMode?: number; + protectedWhitespaces?: boolean; + } + + namespace htmlParser { + class basicWriter { + constructor(); + attribute(attName: string, attValue: string): void; + closeTag(tagName: string): void; + comment(comment: string): void; + getHtml(reset: boolean): string; + openTag(tagName: string, attributes: { [key: string]: string }): void; + openTagClose(tagName: string, isSelfClose: boolean): void; + reset(): void; + text(text: string): void; + write(data: string): void; + } + + class cdata extends node { + constructor(value: string); + type: number; + writeHtml(writer: htmlParser.basicWriter): void; + } + + class comment extends node { + type: number; + value: string; + + constructor(value: string); + filter(filter: filter): boolean; + writeHtml(writer: htmlParser.basicWriter, filter?: htmlParser.filter): void; + } + + class cssStyle { + constructor(elementOrStyleText: htmlParser.element | string); + populate(obj: htmlParser.element | dom.element | { [key: string]: any}): void; + } + + class element extends node { + attributes: { [name: string]: string }; + children: htmlParser.node[]; + name: string; + type: number; + + constructor(name: string, attributes: { [name: string]: string }); + add(node: node, index?: number): void; + addClass(className: string): void; + clone(): element; + filter(filter: htmlParser.filter): boolean; + filterChildren(filter: htmlParser.filter): void; + find(criteria: string | ((el: htmlParser.node) => boolean), recursive?: boolean): htmlParser.node[]; + forEach(callback: (node: htmlParser.node) => void | false, type?: number, skipRoot?: boolean): void; + getFirst(condition: string | { [key: string]: string } | ((node: htmlParser.node) => boolean)): htmlParser.node; + getHtml(): string; + getOuterHtml(): string; + hasClass(className: string): boolean; + removeClass(className: string): void; + replaceWithChildren(): void; + setHtml(html: string): void; + split(index: number): htmlParser.element; + writeChildrenHtml(writer: htmlParser.basicWriter, filter?: htmlParser.filter): void; + writeHtml(writer: basicWriter, filter?: htmlParser.filter): void; + } + + class filter { + attributeNameRules: filterRulesGroup; + attributesRules: { [name: string]: filterRulesGroup }; + commentRules: filterRulesGroup; + elementNameRules: filterRulesGroup; + elementsRules: { [name: string]: filterRulesGroup }; + id: number; + rootRules: filterRulesGroup; + textRules: filterRulesGroup; + + constructor(rules?: filterRulesDefinition); + addRules(rules: filterRulesDefinition, options?: number | { priority?: number; applyToAll?: boolean; }): void; + applyTo(node: node): void; + } + + interface filterRulesDefinition { + elementNames: any; + attributeNames: any; + elements: any; + attributes: any; + text: any; + comment: any; + root: any; + } + + class filterRulesGroup { + rules: { value: rule, priority: number, option: ruleOptions }[]; + + add(rule: rule, priority: number, options: ruleOptions): void; + addMany(rules: { [key: string]: any }[], priority: number, options: ruleOptions): void; + exec(currentValue: htmlParser.node | htmlParser.fragment | string): htmlParser.node | htmlParser.fragment | string; + execOnName(currentName: string): string; + findIndex(priority: number): number; + } + + class fragment { + children: htmlParser.node[]; + parent: htmlParser.fragment; + readonly type: number; + + constructor(); + + add(node: htmlParser.node, index?: number): void; + filter(filter: htmlParser.filter): void; + filterChildren(filter: htmlParser.filter, filterRoot?: boolean): void; + forEach(callback: (node: htmlParser.node,) => void | false, type?: number, skipRoot?: boolean): void; + writeChildrenHtml(writer: basicWriter, filter?: htmlParser.filter, filterRoot?: boolean): void; + writeHtml(writer: basicWriter, filter?: htmlParser.filter): void; + + static fromBBCode(source: string): htmlParser.fragment; + static fromHtml(fragmentHtml: string, parent?: htmlParser.element | string, fixingBlock?: string | boolean): fragment | htmlParser.element; + } + + class node { + constructor(); + getAscendant(condition: string | { [name: string]: string | ((node: htmlParser.element) => boolean)}): element; + getIndex(): number; + insertAfter(node: node): void; + insertBefore(node: node): void; + remove(): node; + replaceWith(node: node): void; + wrapWith(wrapper: element): element; + } + + type rule = ((value: htmlParser.node | htmlParser.fragment | string) => boolean) | [ string, string ]; + + interface ruleOptions { + applyToAll?: boolean, + excludeNestedEditable?: boolean + } + + class text extends node { + constructor(value: string); + type: number; + filter(filter: filter): boolean; + writeHtml(writer: basicWriter, filter?: filter): void; + } + } + + class htmlWriter extends htmlParser.basicWriter { + indentationChars: string; + lineBreakChars: string; + selfClosingEnd: string; + + indentation(): void; + lineBreak(): void; + setRules(tagName: string, rules: { [key: string]: any }): void; + } + + class keystrokeHandler { + blockedKeystrokes: { [key: number]: string | boolean }; + keystrokes: { [key: number]: string | boolean }; + + constructor(editor: editor); + + attach(domObject: dom.domObject): void; + } + + namespace lang { + var languages: { [code: string]: number }; + var rtl: { [code: string]: number }; + + function detect(defaultLanguage: string, probeLanguage?: string): string; + function load(languageCode: string, defaultLanguage: string, callback: (code: string, entries: any) => void): void; + } + + namespace loader { + var loadedScripts: string[]; + var scripts: string[]; + + function load(scriptName: string, defer?: boolean): void; + function loadPending(): void; + } + + class menu { + constructor(); + + add(item: any): void; + addListener(listenerFn: (startElement: dom.element, selection: dom.selection, path: dom.elementPath) => any): void; + findItemByCommandName(commandName: string): { item: any, element: dom.element }; + hide(returnFocus?: boolean): void; + removeAll(): void; + show(offsetParent: dom.element, corner?: number, offsetX?: number, offsetY?: number): void; + } + + interface pluginDefinition { + hidpi?: boolean; + lang?: string | string[]; + requires?: string | string[]; + + afterInit?(editor: editor): any; + beforeInit?(editor: editor): any; + init?(editor: editor): void; + onLoad?(): any; + } + + namespace plugins { + + namespace cloudservices { + class cloudServicesLoader extends fileTools.fileLoader { + customToken: string; + + constructor(editor: editor, fileOrData: Blob | string, fileName?: string, token?: string); + loadAndUpload(url?: string, additionalRequestParameters?: any): void; + upload(url?: string, additionalRequestParameters?: any): void; + } + } + + class autoEmbed { + getWidgetDefinition(editor: editor, url: string): widget.definition; + } + + namespace balloontoolbar { + const PRIORITY: { [pri: string]: number }; + + class context { + editor: editor; + options: contextDefinition; + toolbar: ui.balloonToolbar; + + constructor(editor: editor, options: contextDefinition); + destroy(): void; + hide(): void; + refresh(): void; + show(pointedElement?: dom.element): void; + } + + interface contextDefinition { + cssSelector?: string; + priority?: number; + widgets?: string[] | string; + + refresh?: (editor: editor, path: dom.elementPath, selection: dom.selection) => dom.element; + } + + class contextManager { + editor: editor; + + constructor(editor: editor); + add(context: context): void; + check(selection?: dom.selection): void; + create(options: contextDefinition): context; + destroy(): void; + hide(): void; + } + } + + namespace clipboard { + const isCustomCopyCutSupported: boolean; + const isCustomDataTypesSupported: boolean; + const isFileApiSupported: boolean; + const mainPasteEvent: string; + + function addPasteButton(editor: editor, name: string, definition: { [key: string]: any}): void; + function canClipboardApiBeTrusted(dataTransfer: dataTransfer, editor: editor): boolean; + function getDropTarget(editor: editor): dom.domObject; + function getRangeAtDropPosition(domEvent: Event, editor: editor): dom.range; + function initDragDataTransfer(evt?: dom.event, editor?: editor): void; + function initPasteDataTransfer(evt?: dom.event, sourceEditor?: editor): void; + function preventDefaultDropOnElement(element: dom.element): void; + function resetDragDataTransfer(): void; + + class dataTransfer { + readonly $: DataTransfer; + readonly id: string; + readonly sourceEditor: editor; + + constructor(nativeDataTransfer?: DataTransfer, editor?: editor); + cacheData(): void; + getData(type: string, getNative?: boolean): string; + getFile(i: number): File; + getFilesCount(): number; + getTransferType(targetEditor: editor): number; + isEmpty(): boolean; + setData(type: string, value: string): void; + storeId(): void; + } + + class fallbackDataTransfer { + constructor(dataTransfer: dataTransfer); + getData(type: string, getNative?: boolean): string; + isRequired(): boolean; + setData(type: string, value: string): string; + } + } + + namespace condesnippet { + function setHighlighter(highlighter: highlighter): void; + + class highlighter { + highlighter: (code: string, lang: string, callback: (highlightedCode: string) => void) => void; + init: (ready: () => void) => void; + languages: { [lang: string]: string }; + readonly queue: ((code: string, lang: string, callback: (highlightedCode: string) => void) => void)[]; + readonly ready: boolean; + + highlight(code: string, lang: string, callback: (highlightedCode: string) => void): void; + } + } + + class contextMenu extends menu { + constructor(editor: editor); + addTarget(element: dom.element, nativeContextMenuOnCtrl?: boolean): void; + open(offsetParent: dom.element, corner?: number, offsetX?: number, offsetY?: number): void; + } + + namespace copyformatting { + var breakOnElements: string[]; + var elementsForInlineTransform: string[]; + var excludedAttributes: string[]; + var excludedAttributesFromInlineTransform: string[]; + var inlineBoundary: string[]; + var preservedElements: string[]; + + class state extends event { + editor: editor; + filter: filter; + sticky: boolean; + styles: style[]; + + constructor(editor: editor); + } + } + + namespace easyimage { + + } + + namespace embedBase { + function createWidgetBaseDefinition(editor: editor): baseDefinition; + + interface baseDefinition extends widget.definition { + providerUrl: template; + urlRegExp: RegExp; + + getErrorMessage(messageTypeOrMessage: string, url?: string, suffix?: string): string; + isUrlValid(url: string): boolean; + loadContent(url: string, callback?: () => void, errorCallback?: (error: string) => void, noNotifications?: boolean): request; + } + + interface request { + callback: () => void; + errorCallback: (error: string) => void; + response: { [key: string]: string }; + task: notificationAggregator.task; + url: string; + + cancel(): void; + } + } + + namespace image2 { + function checkHasNaturalRatio(image: dom.element): boolean; + function getLinkAttributesGetter(): (editor: editor, data: { [key: string]: string }) => { set: { [tag: string]: string }, removed: string[] }; + function getLinkAttributesParser(): (editor: editor, element: dom.element) => { [key: string]: string }; + function getNatural(image: dom.element): { [key: string]: string }; + } + + namespace imagebase { + var featuresDefinitions: { [key: string]: string }; + + function addFeature(editor: editor, name: string, definition: imageWidgetDefinition): imageWidgetDefinition; + function addImageWidget(editor: editor, name: string, definition: imageWidgetDefinition): void; + + interface imageWidgetDefinition extends widget.definition { + features: string[]; + upcast: string; + } + + class progressBar extends progressReporter { + bar: dom.element; + + constructor(); + + } + + class progressReporter { + wrapper: dom.element; + + constructor(wrapperHtml?: string); + aborted(): void; + bindLoader(loader: fileTools.fileLoader): void; + done(): void; + failed(): void; + remove(): void; + updated(progress: number): void; + } + } + + namespace indent { + function registerCommands(editor: editor, commands: { [key: string]: command} ): void; + + class genericDefinition implements commandDefinition { + async: boolean; + canUndo: boolean; + context: boolean; + contextSensitive: boolean; + editorFocus: boolean; + fakeKeystroke: number; + readonly isIndent: boolean; + modes: { [key: string]: any }; + readOnly: boolean; + startDisabled: boolean; + + exec(editor: editor, data?: any): boolean; + refresh?(editor: editor, path: dom.elementPath): void; + } + + class specificDefinition { + database: { [key: string]: any }; + readonly enterBr: boolean; + readonly indentKey: { [key: string]: any }; + readonly isIndent: boolean; + readonly jobs: { [priority: string]: { refresh: (editor: editor, path: dom.elementPath) => number, exec: (editor: editor) => boolean } }; + readonly relatedGlobal: { [key: string]: any }; + + execJob(editor: editor, priority: number): boolean; + getContext(node: dom.elementPath): dom.element; + refreshJob(editor: editor, priority: number): number; + } + } + + namespace indentList { + function firstItemInPath(query: string | string[] | { [tagName: string]: any} | dom.element | ((element: dom.element) => boolean)): boolean; + } + + namespace link { + // DEPRECATED 4.3.3 + const emptyAnchorFix: boolean; + + // DEPRECATED 4.3.3 + const fakeAnchor: boolean; + + // DEPRECATED 4.3.3 + const synAnchorSelector: boolean; + + function getEditorAnchors(editor: editor): dom.element[]; + function getLinkAttributes(editor: editor, data: { [key: string]: any}): { set: { [key: string]: string }, removed: string[] } + function getSelectedLink(editor: editor, returnMultiple?: boolean): dom.element | dom.element[]; + function parseLinkAttributes(editor: editor, element: dom.element): { [key: string]: any }; + function showDisplayTextForElement(element: dom.element, editor: editor): boolean; + function tryRestoreFakeAnchor(editor: editor, element: dom.element): dom.element; + } + + class list { + arrayToList(listArray: any, database: any, paragraphMode: any, dir: any): void; + listToArray(listNode: any, database: any, baseArray: any, baseIndentLevel: any, grandparentNode: any): void; + } + + class notification { + readonly area: notification.area; + readonly duration: number; + readonly editor: editor; + readonly element: dom.element; + readonly id: number; + readonly message: string; + readonly progress: number; + readonly type: notification.type; + + constructor(editor: editor, options: notification.options); + hide(): void; + isVisible(): boolean; + show(): void; + update(options: notification.updateOptions): void; + } + + namespace notification { + interface area { + readonly editor: editor; + readonly element: dom.element; + readonly notifications: notification[]; + + add(notification: notification): void; + remove(notification: notification): void; + } + + interface optionsBase { + duration?: number; + progress?: number; + type?: type; + } + + interface options extends optionsBase { + message: string; + } + + interface updateOptions extends optionsBase { + message?: string; + important?: boolean; + } + + type type = 'info' | 'warning' | 'success' | 'progress'; + } + + class notificationAggregator extends event { + readonly editor: editor; + readonly notification: notification; + + constructor(editor: editor, message: string, singularMessage?: string); + createTask(options?: { weight?: number }): notificationAggregator.task; + getDoneTaskCount(): number; + getPercentage(): number; + getTaskCount(): number; + isFinished(): boolean; + update(): void; + } + + namespace notificationAggregator { + class task extends event { + constructor(weight?: number); + cancel(): void; + done(): void; + isCanceled(): boolean; + isDone(): boolean; + update(weight: number): void; + } + } + + namespace pastefromword { + class lists { + numbering: lists.numbering; + } + + namespace lists { + class numbering { + getStyle(marker: string): string; + toNumber(marker: string, markerType: string): number; + } + } + + class styles { + pushStylesLower(element: htmlParser.element, exceptions: { [style: string]: boolean }, wrapText?: boolean ): boolean; + } + } + + namespace tableselection { + function getCellsBetween(first: dom.element, last: dom.element): dom.element[]; + } + + namespace widget { + var WRAPPER_CLASS_PREFIX: string; + + function getNestedEditable(guard: dom.element, node: dom.node): dom.element; + function isDomDragHandler(node: dom.node): boolean; + function isDomDragHandlerContainer(node: dom.node): boolean; + function isDomNestedEditable(node: dom.node): boolean; + function isDomWidget(node: dom.node): boolean; + function isDomWidgetElement(node: dom.node): boolean; + function isDomWidgetWrapper(node: dom.node): boolean; + function isParserWidgetElement(node: dom.node): boolean; + function isParserWidgetWrapper(node: dom.node): boolean; + + namespace nestedEditable { + interface definition { + allowedContent?: filter.allowedContentRules; + disallowedContent?: filter.disallowedContentRules; + pathName?: string; + selector?: string; + } + } + + class nestedEditable extends dom.element { + readonly editor: editor; + readonly enterMode: number; + readonly filter: filter; + readonly shiftEnterMode: number; + + constructor(editor: editor, element: dom.element, config: { filter?: filter }); + getData(): string; + setData(data: string): void; + } + + + interface definition extends feature { + button?: string; + data?: (evt: eventInfo) => void; + defaults?: { [key: string]: any }; + dialog?: string; + downcast?: string | ((element: htmlParser.element) => void); + downcasts?: { [key: string]: any }; + draggable?: boolean; + edit?: () => void; + editables?: { [key: string]: any }; + getLabel?: () => any; + init?: () => void; + inline?: boolean; + insert?: () => void; + mask?: boolean; + parts?: { [key: string]: any }; + pathName?: string; + styleToAllowedContentRules?: (style: style) => filter.allowedContentRules; + styleableElements?: string; + template?: string | template; + upcast?: string | ((element: htmlParser.element, data: any) => boolean); + upcastPriority?: number; + upcasts?: { [key: string]: any }; + } + + class repository extends event { + readonly editor: editor; + readonly focused: widget; + readonly instances: { [id: string]: widget }; + readonly registered: { [name: string]: definition }; + readonly selected: widget[]; + readonly widgetHoldingFocusedEditable: widget; + + add(name: string, widgetDef: plugins.widget.definition): void; + addUpcastCallback(callback: (element: htmlParser.element, data: any) => boolean): void; + checkSelection(): void; + checkWidgets(options?: { initOnlyNew?: boolean; focusInited?: boolean }): void; + del(widget: plugins.widget): void; + destroy(widget: plugins.widget, offline?: boolean): void; + destroyAll(offline?: boolean): void; + finalizeCreation(container: any): void; + getByElement(element: any, checkWrapperOnly: boolean): plugins.widget; + initOn(element: dom.element, widgetDef?: plugins.widget.definition, startupData?: { [key: string]: any }): plugins.widget; + initOn(element: dom.element, widgetDef?: string, startupData?: { [key: string]: any }): plugins.widget; + initOnAll(container?: dom.element): plugins.widget[]; + parseElementClasses(classes: string): any; + wrapElement(element: any, widgetName?: string): any; + } + + class widgetselection { + addFillers(editable: editable): boolean; + removeFillers(editable: editable): void; + } + } + + class widget extends event implements widget.definition { + readonly dataReady: boolean; + readonly definition: plugins.widget.definition; + readonly editor: editor; + readonly element: dom.element; + readonly focusedEditable: plugins.widget.nestedEditable + readonly id: number; + readonly inited: boolean; + readonly ready: boolean; + readonly repository: plugins.widget.repository; + readonly wrapper: dom.element; + + constructor(widgetsRepo: plugins.widget.repository, id: number, element: dom.element, widgetDef: plugins.widget.definition, starupData?: any); + + addClass(className: string): void; + applyStyle(style: style): void; + checkStyleActive(style: style): boolean; + destroy(offline?: boolean): void; + destroyEditable(editableName: string, offline?: boolean): void; + edit(): boolean; + focus(): void; + getClasses(): any; + hasClass(className: string, Whether: boolean): void; + initEditable(editableName: string, definition: plugins.widget.nestedEditable.definition): boolean; + isInited(): boolean; + isReady(): boolean; + removeClass(className: string): void; + removeStyle(style: style): void; + setData(keyOrData: any, value: any): plugins.widget; + setFocused(selected: boolean): plugins.widget; + setSelected(selected: boolean): plugins.widget; + updateDragHandlerPosition(): void; + } + + function add(name: string, definition: pluginDefinition): void; + function add(name: string): void; + function addExternal(name: string, path: string, fileName?: string): void; + function get(name: string): any; + function getFilePath(name: string): string; + function getPath(name: string): string; + function load(name: string, callback: (plugins: string[]) => void, scope?: { [key: string]: any }): void; + function setLang(pluginName: string, languageCode: string, languageEntries: any): void; + var registered: {[key: string]: pluginDefinition}; + } + + class resourceManager { + basePath: string; + externals: { [key: string]: any }; + fileName: string; + loaded: { [key: string]: any }; + registered: { [key: string]: any }; + + constructor(basePath: string, fileName: string); + add(name: string, definition?: pluginDefinition): void; + addExternal(names: string, path: string, fileName?: string): void; + get(name: string): pluginDefinition; + getFilePath(name: string): string; + getPath(name: string): string; + load(name: string | string[], callback: (loaded: string[]) => void, scope?: { [key: string]: any }): void; + } + + // see https://docs.com/ckeditor4/latest/api/CKEDITOR_scriptLoader.html + namespace scriptLoader { + function load(scriptUrls: string | string[], callback: (succeededUrls: boolean | string[], failedUrls?: string[]) => void, scope?: any, showBusy?: boolean): void; + function queue(scriptUrl: string, callback?: (succeeded: boolean) => void): void; + } + + namespace skin { + var icons: { [name: string]: { path: string } }; + var name: string; + var ua: { [name: string]: any }; + + function addIcon(name: string, path: string, offset?: number, bgsize?: string): void; + function chameleon(editor: string, part: string): void; + function getIconStyle(name: string, rtl?: boolean, overridePath?: number, overrideBgsize?: string): any; + function getPath(part: string): any; + function loadPart(part: string, fn: () => void): void; + function path(): string; + } + + namespace style { + function addCustomHandler(defintion: customHandler): style; + function getStyleText(style: definition): string; + + namespace customHandlers { + class widget extends style { + group: any[]; + widget: string; + checkElement(element: dom.element): boolean; + getClassesArray(): string[]; + getDefintion(): definition; + removeStylesFromSameGroup(editor: editor): boolean; + } + } + + interface definition { + attributes?: { [att: string]: string }, + element: string, + name?: string, + styles?: { [att: string]: string }, + type?: string | number + } + + interface customHandler { + type: string | number; + setup?: (style: definition) => void; + assignedTo?: number; + } + } + + class style { + alwaysRemoveElement: boolean; + includeReadonly: boolean; + constructor(styleDefinition: style.definition, variableValues: any); + apply(editor: editor): void; + applyToObject(element: dom.element, editor: editor): void; + applyToRange(range: Range, editor: editor): void; + buildPreview(label?: string): string; + checkActive(elementPath: dom.elementPath, editor: editor): boolean; + checkApplicable(elementPath: dom.elementPath, editor: editor, filter?: filter): boolean; + checkElementMatch(element: dom.element, fullMatch: boolean, editor: editor): boolean; + checkElementRemovable(element: dom.element, fullMatch: boolean, editor: editor): boolean; + getDefintion(): style.definition; + remove(editor: editor): void; + removeFromRange(range: Range, editor: editor): void; + toAllowedContentRules(editor?: editor): filter.allowedContentRules; + } + + class styleCommand { + constructor(style: style, ext?: any); + exec(editor: editor): void; + } + + var stylesSet: resourceManager; + + class template { + readonly source: string; + + constructor(source: string); + output(data: any, buffer?: any[]): string | number; + } + + namespace tools { + function addFunction(fn: () => any, scope?: any): number; + function arrayCompare(arrayA: any[], arrayB: any[]): boolean; + function clone(source: { [key: string]: any }): { [key: string]: any }; + function copy(source: { [key: string]: any }): { [key: string]: any }; + function createClass(definition: { [key: string]: any }): any; + function cssStyleToDomStyle(cssName: string): string; + function cssVendorPrefix(property: string, value: string, asString?: boolean): { [cssClass: string]: string | number }; + function defer(fn: T): T; + function enableHtml5Elements(doc: Document | DocumentFragment, withAppend?: boolean): void; + function escapeCss(selector: string): string; + function eventsBuffer(minInterval: number, output: () => void, scopeObj: any): { input: () => void, reset: () => void }; + function extend(target: { [key: string]: any }, source: { [key: string]: any }, overwrite: boolean, properties: { [key: string]: any }): { [key: string]: any }; + function fixDomain(): boolean; + function genKey(subKey: string): string; + function getCookie(name: string): string; + function getCsrfToken(): string; + function getIndex(array: T[], compareFunction: (element: T) => boolean): number; + function getMouseButton(evt: dom.event): boolean; + function getNextId(): string; + function getNextNumber(): number; + function getUniqueId(): string; + function htmlDecode(text: string): string; + function htmlDecodeAttr(text: string): string; + function htmlEncode(text: string): string; + function htmlEncodeAttr(text: string): string; + function indexOf(array: T[], value: T | ((el: T) => boolean)): number; + function isArray(object: any): object is T[]; + function isEmpty(object: { [key: string]: any }): boolean; + function keystrokeToArray(lang: { [key: string]: any }, keystroke: number): { display: string[], aria: string[] }; + function keystrokeToString(lang: { [key: string]: any }, keystroke: number): { display: string, aria: string }; + function ltrim(str: string): string; + function normalizeCssText(styleText: string, nativeNormalize: boolean): string; + function normalizeHex(styleText: string): string; + function objectCompare(left: { [key: string]: any }, right: { [key: string]: any }, onlyLef?: boolean): boolean; + function objectKeys(obj: { [key: string]: any }): string[]; + function override(originalFunction: T, functionBuilder: (originalFunction: T) => T): T; + function parseCssText(styleText: string, normalize?: boolean, nativeNormalize?: boolean): { [key: string]: any }; + function prototypedCopy(source: { [key: string]: any }): { [key: string]: any }; + function removeFunction(ref: number): void; + function repeat(str: string, times: number): string; + function rtrim(str: string): string; + function search(array: T[], value: T | ((element: T) => boolean)): T; + function setCookie(name: string, value: string): void; + function setTimeout(func: Function, milliseconds?: number, scope?: { [key: string]: any }, args?: any, ownerWindow?: Window): number; + function transformPlainTextToHtml(text: string, etnerMode: number): string; + function trim(str: string): string; + function tryThese(fn: Function[]): any; + function writeCssText(styles: { [key: string]: any }, sort?: boolean): string; + + namespace array { + function every(array: T[], fn: (value: T, index: number, array: T[]) => boolean, thisArg?: { [key: string]: any }): boolean; + function filter(array: T[], fn: (value: T, index: number, array: T[]) => boolean, thisArg?: { [key: string]: any }): T[]; + function forEach(array: T[], fn: (value: T, index: number, array: T[]) => void, thisArg?: { [key: string]: any }): void; + function isArray(object: any): boolean; + function map(array: T[], fn: (value: T) => K, thisArg?: { [key: string]: any }): K[]; + function reduce(array: T[], fn: (accumulator: K, a: T, index: number, array: T[]) => K, initial: K, thisArg?: { [key: string]: any }): K; + } + + namespace object { + function findKey(obj: { [key: string]: any }, value: any): string; + function merge(obj1: { [key: string]: any }, obj2: { [key: string]: any }): { [key: string]: any }; + } + + namespace style { + namespace parse { + function background(value: string): { color: string, unprocessed: string}; + function border(value: string): { width: string, style: string, color: string }; + function margin(value: string): { top: number, right: number, bottom: number, left: number }; + } + } + } class ui extends event { constructor(editor: editor); - add(name: string, type: Object, definition: Object): void; + add(name: string, type: { [key: string]: any }, definition: { [key: string]: any }): void; addButton(name: string, definition: buttonDefinition): void; - addHandler(type: Object, handler: Object): void; - } - - class environmentConfig { - air : boolean; - chrome : boolean; - cssClass : string; - edge : boolean; - gecko : boolean; - hc : boolean; - hidpi : boolean; - iOS : boolean; - ie : boolean; - isCompatible : boolean; - mac : boolean; - needsBrFiller : boolean; - needsNbspFiller : boolean; - quirks : boolean; - safari : boolean; - version : number; - webkit : boolean; - secure( ) : boolean; + addHandler(type: { [key: string]: any }, handler: { [key: string]: any }): void; + addRichCombo(name: string, definition: { [key: string]: any }): void; + addToolbarGroup(name: string, previous: number | string, subgroupOf?: string): void; + create(name: string): { [key: string]: any }; + get(name: string): { [key: string]: any }; + space(name: string): dom.element; + spaceId(name: string): string; } namespace ui { namespace dialog { - class uiElement { - eventProcessors: any; - - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[], nodeNameArg?: Function | string, stylesArg?: Function | Object, attributesArg?: Function | Object, contentsArg?: Function | string); // Not sure that the htmlList array type is right. - - accessKeyDown(dialog: CKEDITOR.dialog, key: string): void; - accessKeyUp(dialog: CKEDITOR.dialog, key: string): void; - disable(): void; - enable(): void; - focus(): CKEDITOR.ui.dialog.uiElement; - getDialog(): CKEDITOR.dialog; - getElement(): CKEDITOR.dom.element; - getInputElement(): CKEDITOR.dom.element; - getValue(): any; - isChanged(): boolean; - isEnabled(): boolean; - isFocusable(): boolean; - isVisible(): boolean; - registerEvents(definition: CKEDITOR.dialog.definition.uiElement): CKEDITOR.ui.dialog.uiElement; - selectParentTab(): CKEDITOR.ui.dialog.uiElement; - setValue(value: Object, noChangeEvent: boolean): CKEDITOR.ui.dialog.uiElement; - - // Change event? - } - - class button extends uiElement { - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); + constructor(dialog: dialog, elementDefinition: definitions.button, htmlList: any[]); accessKeyDown(): void; accessKeyUp(): void; click(): any; } - class checkbox extends uiElement { - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); + constructor(dialog: dialog, elementDefinition: definitions.checkbox, htmlList: any[]); accessKeyUp(): void; - getInputElement(): CKEDITOR.dom.element; getValue(): boolean; - setValue(checked: boolean, noChangeEvent: boolean): any; // returns void according to doc, but cannot override base class like that + setValue(checked: boolean, noChangeEvent: boolean): undefined; } + namespace definitions { + interface button { + label: string; + disabled?: boolean; + } + + interface checkbox { + checked?: boolean; + validate?: () => boolean; + label?: string; + } + + interface fieldSet { + label?: string; + children: any[]; + } + + interface file { + validate?: () => boolean; + } + + interface fileButton { + for: string; + validate?: () => boolean; + } + + interface hbox { + widths?: string[]; + height?: string; + padding?: string; + align?: string; + } + + interface html { + html: string; + } + + interface iframeElement { + src: string; + width: string; + height: string; + onContentLoad?: () => void; + } + + interface labeledElement { + label: string; + labelLayout?: 'horizontal' | 'vertical'; + widths?: [ string, string ]; + role?: string; + includeLabel?: boolean; + } + + interface radio { + default: any; + validate?: () => boolean; + items: ([string, string] | [string])[]; + } + + interface select { + default: any; + validate?: () => boolean; + items: ([string, string] | [string])[]; + multiple?: boolean; + size?: number; + } + + interface textarea { + rows?: number; + cols?: number; + default?: string; + validate?: () => boolean; + } + + interface textInput { + default?: string; + validate?: () => boolean; + maxLength?: number; + size?: string; + } + + interface uiElement { + id: string; + type: number; + title?: string; + hidden?: boolean; + className?: string; + style?: string; + accessKey?: string; + } + + interface vbox { + width?: string; + heights?: string[]; + align?: string; + padding?: string; + expand?: boolean; + } + } class fieldset extends uiElement { - constructor(dialog: CKEDITOR.dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: CKEDITOR.dialog.definition.uiElement); + constructor(dialog: dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: definitions.fieldSet); } - class file extends CKEDITOR.ui.dialog.labeledElement { - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); + class file extends ui.dialog.labeledElement { + constructor(dialog: dialog, elementDefinition: definitions.file, htmlList: any[]); getAction(): string; - getInputElement(): CKEDITOR.dom.element; - registerEvents(definition: Object): CKEDITOR.ui.dialog.file; + registerEvents(definition: { [key: string]: any }): file; reset(): void; setInitValue(): void; - submit(): CKEDITOR.ui.dialog.file; + submit(): file; } - class fileButton extends CKEDITOR.ui.dialog.button { - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); - - // formLoaded event ?? + class fileButton extends button { + constructor(dialog: dialog, elementDefinition: definitions.fileButton, htmlList: any[]); } class hbox extends uiElement { - constructor(dialog: CKEDITOR.dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: CKEDITOR.dialog.definition.uiElement); + constructor(dialog: dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: definitions.hbox); - getChild(indices: number): CKEDITOR.ui.dialog.uiElement; - getChild(indices: number[]): CKEDITOR.ui.dialog.uiElement[]; + getChild(indices: number): ui.dialog.uiElement; + getChild(indices: number[]): ui.dialog.uiElement[]; } class html extends uiElement { - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); + constructor(dialog: dialog, elementDefinition: definitions.html, htmlList: any[]); } @@ -1528,422 +2500,272 @@ declare namespace CKEDITOR { class labeledElement extends uiElement { - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[], contentHtml: Function); + constructor(dialog: dialog, elementDefinition: definitions.labeledElement, htmlList: any[], contentHtml: () => string); getLabel(): string; - setlabel(label: string): CKEDITOR.ui.dialog.labeledElement; + setlabel(label: string): ui.dialog.labeledElement; } - class radio extends CKEDITOR.ui.dialog.labeledElement { - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); + class radio extends ui.dialog.labeledElement { + constructor(dialog: dialog, elementDefinition: definitions.radio, htmlList: any[]); accessKeyUp(): void; getValue(): string; - setValue(value: string, noChangeEvent: boolean): any; // returns void according to doc, but cannot override base class like that + setValue(value: string, noChangeEvent: boolean): undefined; } class select extends uiElement { - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); + constructor(dialog: dialog, elementDefinition: definitions.select, htmlList: any[]); - add(label: string, value?: string, indexedDB?: number): CKEDITOR.ui.dialog.select; - clear(): CKEDITOR.ui.dialog.select; - getInputElement(): CKEDITOR.dom.element; - remove(index: number): CKEDITOR.ui.dialog.select; + add(label: string, value?: string, indexedDB?: number): select; + clear(): select; + remove(index: number): select; } - class textarea extends CKEDITOR.ui.dialog.labeledElement { - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); + class textarea extends labeledElement { + constructor(dialog: dialog, elementDefinition: definitions.textarea, htmlList: any[]); } - class textInput extends CKEDITOR.ui.dialog.labeledElement { - constructor(dialog: CKEDITOR.dialog, elementDefinition: CKEDITOR.dialog.definition.uiElement, htmlList: any[]); + class textInput extends ui.dialog.labeledElement { + constructor(dialog: dialog, elementDefinition: definitions.textInput, htmlList: any[]); accessKeyUp(): void; - focus(): any; // returns void according to doc, but cannot override base class like that + focus(): undefined; getDirectionMarker(): string; - getInputElement(): CKEDITOR.dom.element; getValue(): string; select(): void; setDirectionMarker(dir: string): void; - setValue(value: string, noChangeEvent: boolean): CKEDITOR.ui.dialog.textInput; + setValue(value: string, noChangeEvent: boolean): textInput; + } + + class uiElement { + eventProcessors: any; + + constructor(dialog: dialog, elementDefinition: definitions.uiElement, htmlList: any[], nodeNameArg?: () => string | string, stylesArg?: () => { [key: string]: any } | { [key: string]: any }, attributesArg?: () => { [key: string]: any } | { [key: string]: any }, contentsArg?: () => { [key: string]: any } | string); // Not sure that the htmlList array type is right. + + accessKeyDown(dialog: dialog, key: string): void; + accessKeyUp(dialog: dialog, key: string): void; + disable(): void; + enable(): void; + focus(): ui.dialog.uiElement; + getDialog(): dialog; + getElement(): dom.element; + getInputElement(): dom.element; + getValue(): any; + isChanged(): boolean; + isEnabled(): boolean; + isFocusable(): boolean; + isVisible(): boolean; + registerEvents(definition: CKEDITOR.dialog.definition.uiElement): ui.dialog.uiElement; + selectParentTab(): ui.dialog.uiElement; + setValue(value: any, noChangeEvent: boolean): ui.dialog.uiElement; + } + + class vbox extends hbox { + constructor(dialog: dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: definitions.vbox); } } - } - class dialog { - state: number; + class balloonPanel { + activeShowListeners: { [id: number]: { removeListener: listenerRegistration }}; + editor: editor; + focusables: { [id: number]: dom.element }; + height: string; + parts: balloonPanel.parts; + rect: balloonPanel.rect; + showListeners: { [id: number]: () => listenerRegistration }; + templateDefinitions: balloonPanel.templateDefinitions; + templates: balloonPanel.templates; + triangleHeight: number; + triangleMinDistance: number; + triangleWidth: number; + width: number; - constructor(editor: Object, dialogName: string); + activeShowListener(id: number): void; + activateShowListeners(): void; + addShowListener(listener: () => listenerRegistration): listenerRegistration; + attach(element: dom.element, options?: dom.element | boolean | { focusElement?: dom.element | boolean, show?: boolean }): void; + blur(): void; + build(): void; + deactivateShowListener(id: number): void; + deregisterFocusable(element: dom.element): void; + destroy(): void; + getHeight(): number; + getWidth(): number; + hide(): void; + move(top: number, left: number): void; + registerFocusable(element: dom.element): void; + removeShowListener(id: number): void; + resize(width: number, height: number): void; + setTitle(title: string): void; + setTriangle(side: 'left' | 'right' | 'top' | 'bottom'): void; + show(): void; + } - addFocusable(element: CKEDITOR.dom.element, index?: number): void; - addPage(contents: Object): void; - click(id: string): Object; - commitContent(): void; - diableButton(id: string): void; - enableButton(id: string): void; - foreach(fn: Function): CKEDITOR.dialog; - getButton(id: string): CKEDITOR.ui.dialog.button; - getContentElement(pageId: string, elementId: string): CKEDITOR.ui.dialog.uiElement; - getElement(): CKEDITOR.dom.element; - getName(): string; - getPageCount(): number; - getParentEditor(): CKEDITOR.editor; - getPosition(): Object; - getSelectedElement(): CKEDITOR.dom.element; - getSize(): Object; - getValueOf(pageId: string, elementId: string): Object; - hide(): void; - hidePage(id: string): void; - layout(): void; - move(x: number, y: number, save: boolean): void; - reset(): CKEDITOR.dialog; - resize(width: number, height: number): void; - selectPage(id: string): void; - setState(state: number): void; - setValueOf(pageId: string, elementId: string, value: Object): void; - setupContent(): void; - show(): void; - showPage(id: string): void; - updateStyle(): void; - - // NOTE: Static methods are added to dialog module - } - - - namespace dialog { - - namespace definition { - - interface button extends uiElement { - disabled?: boolean; - label?: string; - } - - - interface checkbox extends uiElement { - default?: string; - label?: string; - validate?: Function; - } - - - interface content { - accessKey?: string; - elements?: CKEDITOR.dialog.definition.uiElement[]; - id?: string; - label?: string; + namespace balloonPanel { + interface definition { + content?: string; title?: string; } - - interface file extends labeledElement { - action?: string; - size?: string; - validate?: Function; + interface templates { + close?: template; + content?: template; + panel?: template; + title?: template; + triangle?: template; + triangleInner?: template; + triangleOuter?: template; } - - - interface fileButton extends uiElement { - filebrowser?: string; - for?: string; - label?: string; - styles?: string; + + interface templateDefinitions { + close?: string; + content?: string; + panel?: string; + title?: string; + triangle?: string; + triangleInner?: string; + triangleOuter?: string; } - - - interface hbox extends uiElement { - children?: CKEDITOR.ui.dialog.uiElement[]; + + interface rect { height?: number; - padding?: number; - validate?: Function; - widths?: number[]; + left?: number; + top?: number; + visible?: boolean; + width?: number; } - - - interface html extends uiElement { - html?: string; - } - - - interface labeledElement extends uiElement { - controlStyle?: string; - inputStyle?: string; - label?: string; - labelLayout?: string; - labelStyle?: string; - widths?: number[]; - } - - - interface radio extends labeledElement { - default?: string; - items?: string[] | (string[])[]; - validate?: Function; - } - - - - interface select extends labeledElement { - default?: string; - items?: string[] | (string[])[]; - multiple?: boolean; - size?: number; - validate?: Function; - } - - - - interface textarea extends labeledElement { - bidi?: boolean; - cols?: number; - default?: string; - rows?: number; - validate?: Function; - } - - - interface textInput extends labeledElement { - bidi?: boolean; - default?: string; - maxLength?: number; - size?: number; - validate?: Function; - } - - - interface uiElement { - align?: string; - className?: string; - commit?: (widget: CKEDITOR.plugins.widget) => void; - id?: string; - onHide?: (elem: CKEDITOR.ui.dialog.uiElement) => void; - onLoad?: (elem: CKEDITOR.ui.dialog.uiElement) => void; - onShow?: (elem: CKEDITOR.ui.dialog.uiElement) => void; - requiredcontent?: string | Object | CKEDITOR.style; - setup?: (widget: CKEDITOR.plugins.widget) => void; - style?: string; - title?: string; - type?: string; - } - - - interface vbox extends uiElement { - children?: CKEDITOR.ui.dialog.uiElement[]; - expand?: boolean; - heights?: number[]; - padding?: number; - styles?: string; - width?: number[]; + + interface parts { + close?: dom.element; + content?: dom.element; + panel?: dom.element; + title?: dom.element; + triangle?: dom.element; + triangleInner?: dom.element; + triangleOuter?: dom.element; } } - interface IDialogDefinition { - buttons?: CKEDITOR.dialog.definition.button[]; - contents?: CKEDITOR.dialog.definition.content[]; - height?: number; - minHeight?: number; - minWidth?: number; - onCancel?: Function; - onLoad?: Function; - onOk?: Function; - onShow?: Function; - onHide?: Function; - resizable?: number; - title?: string; - width?: number; + class balloonToolbar { + constructor(editor: editor, definition: { [key: string]: any }); + addItem(name: string, element: button | richCombo): void; + addItems(elements: { [itemName: string]: button | richCombo }): void; + deleteItem(name: string): void; + destroy(): void; + getItem(name: string): button | richCombo; + hide(): void; + refresh(): void; + show(): void; } - function add(name: string, path: string): void; - function add(name: string, dialogDefinition: (editor: CKEDITOR.editor) => IDialogDefinition): void; - function addIframe(name: string, title: string, minWidth: number, minHeight: number, onContentLoad?: Function, userDefinition?: Object): void; - function addUIElement(typeName: string, builder: Function): void; - function cancelButton(): void; - function exists(name: string | number): void; // NOTE: documentation says object, but it's an array accessor, so really a string or number will work - function getCurrent(): CKEDITOR.dialog; - function isTabEnabled(editor: CKEDITOR.editor, dialogName: string, tabName: string): boolean; - function okButton(): void; + class button { + static readonly handler: handlerDefinition + + +
+
+ + + + ); + } +} From 4ad5d42d17dfb697be5834053cb32ba705d2a66d Mon Sep 17 00:00:00 2001 From: Nguyen Xuan Khanh Date: Tue, 22 May 2018 17:52:22 +0700 Subject: [PATCH 049/236] Added Grid children, label, stretchy props Specified children type for some components. Slider: added `max`, `min` props ColorButton: onClick to onChange Removed undocumented components. --- types/proton-native/index.d.ts | 205 ++++++++++++++++----------------- 1 file changed, 101 insertions(+), 104 deletions(-) diff --git a/types/proton-native/index.d.ts b/types/proton-native/index.d.ts index bf06ad879c..b49efe6014 100644 --- a/types/proton-native/index.d.ts +++ b/types/proton-native/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for proton-native 0.55 +// Type definitions for proton-native 1.1 // Project: https://github.com/kusti8/proton-native // Definitions by: Nguyen Xuan Khanh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -18,7 +18,7 @@ export interface AppProps { */ export class App extends React.Component { } -export interface AreaBaseProps { +export interface AreaBaseProps extends GridChildrenProps, Label, Stretchy { /** * The fill color for the component. */ @@ -258,12 +258,7 @@ export class Area extends React.Component { static Rectangle: typeof AreaRectangle; } -/** - * Undocumented - */ -export class AreaInternal extends React.Component { } - -export interface BoxProps { +export interface BoxProps extends GridChildrenProps, Label, Stretchy { /** * Whether the Box is enabled. */ @@ -284,7 +279,11 @@ export interface BoxProps { export class Box extends React.Component { } -export interface ButtonProps { +export interface ButtonProps extends GridChildrenProps, Label, Stretchy { + /** + * The text to display in the button. + */ + children?: string; /** * Whether the button can be clicked. */ @@ -304,15 +303,19 @@ export interface ButtonProps { */ export class Button extends React.Component { } -export interface CheckboxProps { - /** - * Whether the checkbox can be used. - */ - enabled?: boolean; +export interface CheckboxProps extends GridChildrenProps, Label, Stretchy { /** * Whether the checkbox is checked or not. */ checked?: boolean; + /** + * The text to display next to the check box. + */ + children?: string; + /** + * Whether the checkbox can be used. + */ + enabled?: boolean; /** * Called when the checkbox is clicked. The current checkbox state is passed as an argument. */ @@ -325,7 +328,7 @@ export interface CheckboxProps { export class Checkbox extends React.Component { } -export interface ColorButtonProps { +export interface ColorButtonProps extends GridChildrenProps, Label, Stretchy { /** * The initial color for the ColorButton. Can be passed as standard color seen in CSS (a color name, hex, rgb, rgba, hsl, hsla). */ @@ -333,7 +336,7 @@ export interface ColorButtonProps { /** * Called when the color is changed for the ColorButton. The current color is passed as an object of RGBA. */ - onClick?: (color: { + onChange?: (color: { r: number, g: number, b: number, @@ -346,32 +349,7 @@ export interface ColorButtonProps { */ export class ColorButton extends React.Component { } -/** - * Undocumented - */ -export class Combobox extends React.Component { } - -/** - * Undocumented - */ -export class ComboboxItem extends React.Component { } - -/** - * Undocumented - */ -export class EditableCombobox extends React.Component { } - -/** - * Undocumented - */ -export class Entry extends React.Component { } - -/** - * Undocumented - */ -export class FontButton extends React.Component { } - -export interface FormProps { +export interface FormProps extends GridChildrenProps, Stretchy { /** * Whether the Form is enabled. */ @@ -438,7 +416,11 @@ export interface GridProps { */ export class Grid extends React.Component { } -export interface GroupProps { +export interface GroupProps extends GridChildrenProps, Label, Stretchy { + /** + * Group can only have one child. To have more than one child, use boxes. + */ + children?: JSX.Element; /** * Whether the Group is enabled. */ @@ -459,18 +441,17 @@ export interface GroupProps { /** * A named group of components. + * + * **Note:** Group can only have one child. To have more than one child, use boxes */ export class Group extends React.Component { } -/** - * Undocumented - */ -export class HorizontalBox extends React.Component { } - -/** - * Undocumented - */ -export class HorizontalSeparator extends React.Component { } +export interface Label { + /** + * Label for Form and Tab children + */ + label?: string; +} export interface MenuProps { /** @@ -480,6 +461,14 @@ export interface MenuProps { } export interface MenuItemProps { + /** + * The text to display for the menu item. + */ + children?: string; + /** + * If the type is `Check`, then set whether it is checked or not. + */ + checked?: boolean; /** * How the menu item is displayed. * @@ -491,16 +480,15 @@ export interface MenuItemProps { * - `Item` - a normal menu button. This is the default. */ type?: 'Check' | 'Quit' | 'About' | 'Preferences' | 'Separator' | 'Item'; - /** - * If the type is `Check`, then set whether it is checked or not. - */ - checked?: boolean; /** * Called when the menu item is clicked. If the type is `Check`, then it passes whether it is checked as an argument. */ onClick?: (checked: boolean) => void; } +/** + * A single item in a Menu. + */ export class MenuItem extends React.Component { } /** @@ -515,27 +503,7 @@ export class Menu extends React.Component { static Item: typeof MenuItem; } -/** - * Undocumented - */ -export class MenuBar extends React.Component { } - -/** - * Undocumented - */ -export class MenuBarItem extends React.Component { } - -/** - * Undocumented - */ -export class MultilineEntry extends React.Component { } - -/** - * Undocumented - */ -export class PasswordEntry extends React.Component { } - -export interface PickerProps { +export interface PickerProps extends GridChildrenProps, Label, Stretchy { /** * Whether the user can enter their own custom text in addition to the drop down menu. */ @@ -571,7 +539,7 @@ export interface PickerProps { */ export class Picker extends React.Component { } -export interface ProgressBarProps { +export interface ProgressBarProps extends GridChildrenProps, Label, Stretchy { /** * Whether the ProgressBar is enabled. */ @@ -591,14 +559,13 @@ export interface ProgressBarProps { */ export class ProgressBar extends React.Component { } -/** - * Undocumented - */ -export class RadioButton extends React.Component { } +export interface RadioButtonsItemProps { + children: string; +} -export class RadioButtonItem extends React.Component { } +export class RadioButtonsItem extends React.Component { } -export interface RadioButtonsProps { +export interface RadioButtonsProps extends GridChildrenProps, Label, Stretchy { /** * Whether the RadioButtons can be used. */ @@ -623,10 +590,10 @@ export interface RadioButtonsProps { * Every child must be a RadioButtons.Item, that requires a string child that is the label to display to the right of the RadioButton. */ export class RadioButtons extends React.Component { - static Item: typeof RadioButtonItem; + static Item: typeof RadioButtonsItem; } -export interface SeparatorProps { +export interface SeparatorProps extends GridChildrenProps, Label, Stretchy { /** * Whether the Separator is enabled. */ @@ -646,11 +613,19 @@ export interface SeparatorProps { */ export class Separator extends React.Component { } -export interface SliderProps { +export interface SliderProps extends GridChildrenProps, Label, Stretchy { /** * Whether the Slider is enabled. */ enabled?: boolean; + /** + * The minimum value for the slider. + */ + min?: number; + /** + * The maximum value for the slider. + */ + max?: number; /** * Called when the value of the slider is changed. The current value is passed as an argument. */ @@ -670,7 +645,7 @@ export interface SliderProps { */ export class Slider extends React.Component { } -export interface SpinBoxProps { +export interface SpinBoxProps extends GridChildrenProps, Label, Stretchy { /** * Whether the Spinbox is enabled. */ @@ -694,7 +669,20 @@ export interface SpinBoxProps { */ export class SpinBox extends React.Component { } -export interface TabProps { +export interface Stretchy { + /** + * Whether the component should stretch to fill the available space. Defaults to true. + * + * Excluded on: + * - Tabs + * - Grid children + * - Combobox/RadioButton Items + * - MenuBar + */ + stretchy?: boolean; +} + +export interface TabProps extends GridChildrenProps { /** * Whether the Tab is enabled. */ @@ -712,12 +700,23 @@ export interface TabProps { */ export class Tab extends React.Component { } +export interface TextProps extends GridChildrenProps, Label, Stretchy { + /** + * The text to display. + */ + children?: string; +} + /** * Displays some text. */ -export class Text extends React.Component { } +export class Text extends React.Component { } -export interface TextInputProps { +export interface TextInputProps extends GridChildrenProps, Label, Stretchy { + /** + * The default text in the TextInput. + */ + children?: string; /** * Whether the TextInput can be used. */ @@ -749,21 +748,15 @@ export interface TextInputProps { */ export class TextInput extends React.Component { } -/** - * Undocumented - */ -export class VerticalBox extends React.Component { } - -/** - * Undocumented - */ -export class VerticalSeparator extends React.Component { } - export interface WindowProps { /** * Whether the window will have a border on the inside. */ borderless?: boolean; + /** + * Window can only have one child. To have more than one child, use boxes. + */ + children?: JSX.Element; /** * Whether the window is closed. If set to closed, then the window will be closed. */ @@ -810,10 +803,15 @@ export interface WindowProps { /** * The window is the basis where all other components reside. + * + * **Note:** Window can only have one child. To have more than one child, use boxes. */ export class Window extends React.Component { } -export function render(element: JSX.Element): React.ReactNode; +/** + * Renders the input component + */ +export function render(element: JSX.Element): void; /** * A method to display an alert, or a dialog to save or open a file. @@ -830,8 +828,7 @@ export function Dialog( options?: { title: string, description?: string - } - | { + } | { title?: string, description: string } From 571f1889da6d4220551c2b877d2ad24ef40865c5 Mon Sep 17 00:00:00 2001 From: "Amir.Tugi@Gmail.com" Date: Tue, 22 May 2018 15:23:39 +0300 Subject: [PATCH 050/236] Fix tests --- types/express-paginate/express-paginate-tests.ts | 4 ++-- types/express-paginate/index.d.ts | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/types/express-paginate/express-paginate-tests.ts b/types/express-paginate/express-paginate-tests.ts index d31c70362c..20f1a0a558 100644 --- a/types/express-paginate/express-paginate-tests.ts +++ b/types/express-paginate/express-paginate-tests.ts @@ -5,7 +5,7 @@ declare function findAndCountAll(params: object): Promise<{count: number, rows: const app = express(); -app.use(paginate.middleware(10, 50)) +app.use(paginate.middleware(10, 50)); app.get('/users', async (req, res, next) => { // req.skip should be available @@ -22,5 +22,5 @@ app.get('/users', async (req, res, next) => { hasNextPages: paginate.hasNextPages(req)(pageCount), pages: paginate.getArrayPages(req)(3, pageCount, req.query.page) }); - }).catch(err => next(err)) + }).catch(next); }); diff --git a/types/express-paginate/index.d.ts b/types/express-paginate/index.d.ts index 403bd92979..1f722d1b28 100644 --- a/types/express-paginate/index.d.ts +++ b/types/express-paginate/index.d.ts @@ -2,19 +2,20 @@ // Project: https://github.com/niftylettuce/express-paginate // Definitions by: My Self // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.7 import * as express from 'express'; declare global { namespace Express { - export interface Request { - skip?: number, - offset?: number, + interface Request { + skip?: number; + offset?: number; } } } -interface PageElement { +export interface PageElement { number: number; url: typeof href; } From f4f78cffa35452fd094bd52ba38c91e71f89db46 Mon Sep 17 00:00:00 2001 From: Dmitry Mazurok Date: Tue, 22 May 2018 20:45:49 +0700 Subject: [PATCH 051/236] [@types/mem-fs-editor] Add 'commit' override and 'object' -> 'any' --- types/mem-fs-editor/index.d.ts | 29 ++++++++++++---------- types/mem-fs-editor/mem-fs-editor-tests.ts | 16 ++++++++++++ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/types/mem-fs-editor/index.d.ts b/types/mem-fs-editor/index.d.ts index 01234bbc0c..60f5b51867 100644 --- a/types/mem-fs-editor/index.d.ts +++ b/types/mem-fs-editor/index.d.ts @@ -17,30 +17,33 @@ export function create(store: Store): memFsEditor.Editor; export namespace memFsEditor { type Contents = string|Buffer; - type ReplacerFunc = (key: string, value: any) => string|null|undefined; + type ReplacerFunc = (key: string, value: any) => any; type Space = string|number; type ProcessFunc = (contents: Buffer) => Contents; + type Callback = (err: any) => any; + interface CopyOptions { process?: ProcessFunc; globOptions?: GlobOptions; } interface Editor { - read: (filepath: string, options?: { raw: boolean, defaults: string }) => string; - readJSON: (filepath: string, defaults?: string) => string; - write: (filepath: string, contents: Contents) => void; - writeJSON: (filepath: string, contents: object, replacer?: ReplacerFunc, space?: Space) => void; - append: (filepath: string, contents: Contents, options?: { trimEnd: boolean, separator: string }) => void; - extendJSON: (filepath: string, contents: object, replacer?: ReplacerFunc, space?: Space) => void; - delete: (filepath: string, options?: { globOptions: GlobOptions }) => void; - copy: (from: string, to: string, options?: CopyOptions) => void; - copyTpl: (from: string, to: string, context: object, templateOptions?: TemplateOptions, copyOptions?: CopyOptions) => void; - move: (from: string, to: string, options?: { globOptions: GlobOptions }) => void; - exists: (filepath: string) => boolean; - commit: (filters: ReadonlyArray, callback: () => void) => void; + read(filepath: string, options?: { raw: boolean, defaults: string }): string; + readJSON(filepath: string, defaults?: any): any; + write(filepath: string, contents: Contents): void; + writeJSON(filepath: string, contents: any, replacer?: ReplacerFunc, space?: Space): void; + append(filepath: string, contents: Contents, options?: { trimEnd: boolean, separator: string }): void; + extendJSON(filepath: string, contents: object, replacer?: ReplacerFunc, space?: Space): void; + delete(filepath: string, options?: { globOptions: GlobOptions }): void; + copy(from: string, to: string, options?: CopyOptions): void; + copyTpl(from: string, to: string, context: object, templateOptions?: TemplateOptions, copyOptions?: CopyOptions): void; + move(from: string, to: string, options?: { globOptions: GlobOptions }): void; + exists(filepath: string): boolean; + commit(callback: Callback): void; + commit(filters: ReadonlyArray, callback: Callback): void; } const prototype: { diff --git a/types/mem-fs-editor/mem-fs-editor-tests.ts b/types/mem-fs-editor/mem-fs-editor-tests.ts index 355c714bf9..ff3c52c5a0 100644 --- a/types/mem-fs-editor/mem-fs-editor-tests.ts +++ b/types/mem-fs-editor/mem-fs-editor-tests.ts @@ -1,3 +1,5 @@ +import { Transform } from 'stream'; + import memFs = require('mem-fs'); import editor = require('mem-fs-editor'); @@ -16,3 +18,17 @@ fs.copy('template.js', 'template.tpl', { fs.copyTpl('template.tpl', 'output.js', { foo: 'bar' }); + +const obj = fs.readJSON('template.json'); +fs.writeJSON('template.json', obj); +fs.extendJSON('template.json', {qwer: 'asdf'}); + +fs.writeJSON('template.json', 'qwer'); // should not be an error, because the parameter is passed to JSON.stringify and it accepts the string +// fs.extendJSON('template.json', 'qwer'); // should be an error, because it does not make sense to extend a json with string + +// should accept both versions of commit - with filters and without: +const cb = (err: any) => ({adsf: 'adsf'}); +fs.commit(cb); + +const filters: Transform[] = []; +fs.commit(filters, cb); From c1e00e25e96757183996545fd546cd74b38e7e4e Mon Sep 17 00:00:00 2001 From: "Amir.Tugi@Gmail.com" Date: Tue, 22 May 2018 17:32:22 +0300 Subject: [PATCH 052/236] Fill correct metadata --- types/express-paginate/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/express-paginate/index.d.ts b/types/express-paginate/index.d.ts index 1f722d1b28..b816d11b1b 100644 --- a/types/express-paginate/index.d.ts +++ b/types/express-paginate/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for express-paginate 1.0 // Project: https://github.com/niftylettuce/express-paginate -// Definitions by: My Self +// Definitions by: Amir Tugendhaft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.7 From 842c88286cfa9e56e0464b8a34adb2047cd32b70 Mon Sep 17 00:00:00 2001 From: Paito Anderson Date: Tue, 22 May 2018 14:12:07 -0400 Subject: [PATCH 053/236] Update for react-bootstrap-typeahead 3.1 --- types/react-bootstrap-typeahead/index.d.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/types/react-bootstrap-typeahead/index.d.ts b/types/react-bootstrap-typeahead/index.d.ts index 659b2034fd..005a7633ed 100644 --- a/types/react-bootstrap-typeahead/index.d.ts +++ b/types/react-bootstrap-typeahead/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for react-bootstrap-typeahead 2.3 +// Type definitions for react-bootstrap-typeahead 3.1 // Project: https://github.com/ericgio/react-bootstrap-typeahead // Definitions by: Guymestef // Rajab Shakirov +// Paito Anderson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 // TODO: ,
, , components @@ -75,8 +76,8 @@ export interface TypeaheadProps { /* Specify which option key to use for display or a render function. By default, the selector will use the label key. */ labelKey?: string | ((option: T | string) => string); - /* Maximum height of the dropdown menu, in px. */ - maxHeight?: number; + /* Maximum height of the dropdown menu. */ + maxHeight?: string; /* Maximum number of results to display by default. Mostly done for performance reasons so as not to render too many DOM nodes in the case of large data sets. */ @@ -100,8 +101,8 @@ export interface TypeaheadProps { /* Invoked when the input is focused. Receives an event. */ onFocus?: (e: Event) => any; - /* Invoked when the input value changes. Receives the string value of the input. */ - onInputChange?: (input: string) => any; + /* Invoked when the input value changes. Receives the string value of the input, as well as the original event. */ + onInputChange?: (input: string, e: Event) => any; /* Invoked when a key is pressed. Receives an event. */ onKeyDown?: (e: Event) => any; @@ -141,9 +142,6 @@ export interface TypeaheadProps { /* Allows selecting the hinted result by pressing enter. */ selectHintOnEnter?: boolean; - - /* Propagate event to parent form. */ - submitFormOnEnter?: boolean; } export const Typeahead: React.ClassicComponentClass>; From 1aec142aa496f285d8125cc720b7580acd54c7dd Mon Sep 17 00:00:00 2001 From: Paito Anderson Date: Tue, 22 May 2018 14:14:16 -0400 Subject: [PATCH 054/236] Added tests --- .../react-bootstrap-typeahead-tests.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/react-bootstrap-typeahead/react-bootstrap-typeahead-tests.tsx b/types/react-bootstrap-typeahead/react-bootstrap-typeahead-tests.tsx index 425bfe313b..10237b1fa0 100644 --- a/types/react-bootstrap-typeahead/react-bootstrap-typeahead-tests.tsx +++ b/types/react-bootstrap-typeahead/react-bootstrap-typeahead-tests.tsx @@ -24,6 +24,8 @@ class BasicExample extends React.Component { labelKey="name" multiple={multiple} options={options} + maxHeight='300px' + onInputChange={(value, e) => {}} placeholder="Choose a state..." /> From fd5fd9a23bac3e7a6b000c7413df937e8d40be48 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 22 May 2018 17:31:29 -0500 Subject: [PATCH 055/236] Update index.d.ts Per documentation at [1] array of data might be numbers or Date objects. [1] http://dygraphs.com/data.html#array --- types/dygraphs/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/dygraphs/index.d.ts b/types/dygraphs/index.d.ts index 6e45d5ccd7..4a4a9f0492 100644 --- a/types/dygraphs/index.d.ts +++ b/types/dygraphs/index.d.ts @@ -6,7 +6,7 @@ /// declare namespace dygraphs { - type DataArray = number[][]; + type DataArray = (number|Date)[][]; type Data = string | DataArray | google.visualization.DataTable; From f74c0ea5a182d10087e865583f4652bd3a724391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Johansen=20Amundrud?= Date: Wed, 23 May 2018 01:47:39 +0200 Subject: [PATCH 056/236] Add optional and null --- .../facebook-instant-games/facebook-instant-games-tests.ts | 2 +- types/facebook-instant-games/index.d.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/facebook-instant-games/facebook-instant-games-tests.ts b/types/facebook-instant-games/facebook-instant-games-tests.ts index 949782c41a..6223c3d5e3 100644 --- a/types/facebook-instant-games/facebook-instant-games-tests.ts +++ b/types/facebook-instant-games/facebook-instant-games-tests.ts @@ -1,5 +1,5 @@ const locale: string = FBInstant.getLocale()!; -const platform: string = FBInstant.getPlatform(); +const platform: string = FBInstant.getPlatform()!; const sdkVersion: string = FBInstant.getSDKVersion(); FBInstant.initializeAsync().then(() => {}); FBInstant.setLoadingProgress(10); diff --git a/types/facebook-instant-games/index.d.ts b/types/facebook-instant-games/index.d.ts index 74c93c6c96..2e6da873cd 100644 --- a/types/facebook-instant-games/index.d.ts +++ b/types/facebook-instant-games/index.d.ts @@ -33,7 +33,7 @@ declare namespace FBInstant { /** * The platform on which the game is currently running. The value will always be null until FBInstant.initializeAsync() resolves. */ - function getPlatform(): Platform; + function getPlatform(): Platform | null; /** * The string representation of this SDK version. @@ -458,7 +458,7 @@ declare namespace FBInstant { * @throws PENDING_REQUEST * @throws CLIENT_UNSUPPORTED_OPERATION */ - chooseAsync(options: ContextOptions): Promise; + chooseAsync(options?: ContextOptions): Promise; /** * Attempts to create or switch into a context between a specified player and the current player. The returned promise will reject if the player listed is not a Connected Player of the current @@ -521,7 +521,7 @@ declare namespace FBInstant { * @throws INVALID_OPERATION * @throws RATE_LIMITED */ - setScoreAsync(score: number, extraData: string): Promise; + setScoreAsync(score: number, extraData?: string): Promise; /** * Retrieves the leaderboard's entry for the current player, or null if the player has not set one yet. From 69e739a7ab02312393774f44a63e659507da22dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Johansen=20Amundrud?= Date: Wed, 23 May 2018 01:58:50 +0200 Subject: [PATCH 057/236] Add missing function for testing leaderboard --- .../facebook-instant-games/facebook-instant-games-tests.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/facebook-instant-games/facebook-instant-games-tests.ts b/types/facebook-instant-games/facebook-instant-games-tests.ts index 6223c3d5e3..cf93053288 100644 --- a/types/facebook-instant-games/facebook-instant-games-tests.ts +++ b/types/facebook-instant-games/facebook-instant-games-tests.ts @@ -70,6 +70,12 @@ FBInstant.getLeaderboardAsync("name").then((leaderboard: FBInstant.Leaderboard) const score: number = leaderboardEntry.getScore(); const timestamp: number = leaderboardEntry.getTimestamp(); }); + const contextID: string = leaderboard.getContextID()!; + leaderboard.getEntriesAsync(10, 10).then(entries => {}); + leaderboard.getEntryCountAsync().then((entryCount: number) => {}); + const name = leaderboard.getName(); + leaderboard.getPlayerEntryAsync().then(playerEntry => {}); + leaderboard.setScoreAsync(10).then(leaderboardEntry => {}); }); FBInstant.player.canSubscribeBotAsync().then((canSubscribeBot: boolean) => {}); From b78b4d15d4c0de3ac5c5cd51d3d2e866c8c91544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Johansen=20Amundrud?= Date: Wed, 23 May 2018 02:03:25 +0200 Subject: [PATCH 058/236] Plural spelling --- types/facebook-instant-games/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/facebook-instant-games/index.d.ts b/types/facebook-instant-games/index.d.ts index 2e6da873cd..c0722b11ec 100644 --- a/types/facebook-instant-games/index.d.ts +++ b/types/facebook-instant-games/index.d.ts @@ -174,11 +174,11 @@ declare namespace FBInstant { * * @param eventName Name of the event. Must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. * @param valueToSum An optional numeric value that FB Analytics can calculate a sum with. - * @param parameter An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, + * @param parameters An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, * and can only contain '_', '-', ' ', and alphanumeric characters. Values must be less than 100 characters in length. * @returns The error if the event failed to log; otherwise returns null. */ - function logEvent(eventName: string, valueToSum?: number, parameter?: { [key: string]: string; }): APIError | null; + function logEvent(eventName: string, valueToSum?: number, parameters?: { [key: string]: string; }): APIError | null; /** * Set a callback to be fired when a pause event is triggered. From f46cd6448bb8ba489848cbd6a3df0eccfcf17592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Johansen=20Amundrud?= Date: Wed, 23 May 2018 02:20:51 +0200 Subject: [PATCH 059/236] Add type --- types/facebook-instant-games/facebook-instant-games-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/facebook-instant-games/facebook-instant-games-tests.ts b/types/facebook-instant-games/facebook-instant-games-tests.ts index cf93053288..f8fc559360 100644 --- a/types/facebook-instant-games/facebook-instant-games-tests.ts +++ b/types/facebook-instant-games/facebook-instant-games-tests.ts @@ -73,7 +73,7 @@ FBInstant.getLeaderboardAsync("name").then((leaderboard: FBInstant.Leaderboard) const contextID: string = leaderboard.getContextID()!; leaderboard.getEntriesAsync(10, 10).then(entries => {}); leaderboard.getEntryCountAsync().then((entryCount: number) => {}); - const name = leaderboard.getName(); + const name: string = leaderboard.getName(); leaderboard.getPlayerEntryAsync().then(playerEntry => {}); leaderboard.setScoreAsync(10).then(leaderboardEntry => {}); }); From 202a537935e6aba0a26129968475d56ad238d453 Mon Sep 17 00:00:00 2001 From: stuartlo Date: Tue, 22 May 2018 18:23:25 -0700 Subject: [PATCH 060/236] Fix boolean issue --- types/ckeditor/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/ckeditor/index.d.ts b/types/ckeditor/index.d.ts index b6cef62744..44c40f3699 100644 --- a/types/ckeditor/index.d.ts +++ b/types/ckeditor/index.d.ts @@ -221,7 +221,7 @@ declare namespace CKEDITOR { breakParent(parent: element): void; contains(node: node): boolean; copyAttributes(dest: element, skipAttributes: { [key: string]: string }): void; - data(name: string, value?: string | false): string; + data(name: string, value?: string | boolean): string; disableContextMenu(): void; find(selector: string): nodeList; findOne(selector: string): element; @@ -1533,7 +1533,7 @@ declare namespace CKEDITOR { filter(filter: htmlParser.filter): boolean; filterChildren(filter: htmlParser.filter): void; find(criteria: string | ((el: htmlParser.node) => boolean), recursive?: boolean): htmlParser.node[]; - forEach(callback: (node: htmlParser.node) => void | false, type?: number, skipRoot?: boolean): void; + forEach(callback: (node: htmlParser.node) => void | boolean, type?: number, skipRoot?: boolean): void; getFirst(condition: string | { [key: string]: string } | ((node: htmlParser.node) => boolean)): htmlParser.node; getHtml(): string; getOuterHtml(): string; @@ -1591,7 +1591,7 @@ declare namespace CKEDITOR { add(node: htmlParser.node, index?: number): void; filter(filter: htmlParser.filter): void; filterChildren(filter: htmlParser.filter, filterRoot?: boolean): void; - forEach(callback: (node: htmlParser.node,) => void | false, type?: number, skipRoot?: boolean): void; + forEach(callback: (node: htmlParser.node,) => void | boolean, type?: number, skipRoot?: boolean): void; writeChildrenHtml(writer: basicWriter, filter?: htmlParser.filter, filterRoot?: boolean): void; writeHtml(writer: basicWriter, filter?: htmlParser.filter): void; From 7f820b490e27ed3cabb8c013ab56b355e7b99fd8 Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Tue, 22 May 2018 22:06:29 -0700 Subject: [PATCH 061/236] Fix #25954 --- types/googlemaps/googlemaps-tests.ts | 20 ++++++++++++++++++++ types/googlemaps/index.d.ts | 19 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/types/googlemaps/googlemaps-tests.ts b/types/googlemaps/googlemaps-tests.ts index 973a15d03f..561e53f91a 100644 --- a/types/googlemaps/googlemaps-tests.ts +++ b/types/googlemaps/googlemaps-tests.ts @@ -40,6 +40,26 @@ let map: google.maps.Map = new google.maps.Map( mapOptions ); +/***** Fitting map to bounds *****/ +map.fitBounds({ + north: 10, + east: 10, + west: 10, + south: 10 +}, 50); + +map.fitBounds({ + east: 10, + north: 10, + south: 10, + west: 10 +}, { + bottom: 100, + left: 150, + right: 150, + top: 50 +}); + /***** Data *****/ diff --git a/types/googlemaps/index.d.ts b/types/googlemaps/index.d.ts index 5c4cca2eb3..9430698fe6 100644 --- a/types/googlemaps/index.d.ts +++ b/types/googlemaps/index.d.ts @@ -1,6 +1,14 @@ // Type definitions for Google Maps JavaScript API 3.30 // Project: https://developers.google.com/maps/ -// Definitions by: Folia A/S , Chris Wrench , Kiarash Ghiaseddin , Grant Hutchins , Denis Atyasov , Michael McMullin , Martin Costello , Sven Kreiss +// Definitions by: Folia A/S , +// Chris Wrench , +// Kiarash Ghiaseddin , +// Grant Hutchins , +// Denis Atyasov , +// Michael McMullin , +// Martin Costello , +// Sven Kreiss +// Umar Bolatov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /* @@ -31,7 +39,7 @@ declare namespace google.maps { /***** Map *****/ export class Map extends MVCObject { constructor(mapDiv: Element|null, opts?: MapOptions); - fitBounds(bounds: LatLngBounds|LatLngBoundsLiteral, padding?: number): void; + fitBounds(bounds: LatLngBounds|LatLngBoundsLiteral, padding?: number|Padding): void; getBounds(): LatLngBounds|null|undefined; getCenter(): LatLng; getDiv(): Element; @@ -58,6 +66,13 @@ declare namespace google.maps { setClickableIcons(clickable: boolean): void; } + export interface Padding { + bottom: number; + left: number; + right: number; + top: number; + } + export interface MapOptions { /** * Color used for the background of the Map div. This color will be visible when From bb5c9b6271338b89b4030942df1c36032963bb32 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 23 May 2018 09:56:05 +0200 Subject: [PATCH 062/236] sharepoint: removed useless PageCOntextInfoInstance --- types/sharepoint/index.d.ts | 46 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/types/sharepoint/index.d.ts b/types/sharepoint/index.d.ts index 5340aa5983..7238e6c2b8 100644 --- a/types/sharepoint/index.d.ts +++ b/types/sharepoint/index.d.ts @@ -108,31 +108,29 @@ declare namespace SP { class PageContextInfo { constructor(); - get_siteServerRelativeUrl(): string; - get_webServerRelativeUrl(): string; - get_webAbsoluteUrl(): string; - get_serverRequestPath(): string; - get_siteAbsoluteUrl(): string; - get_webTitle(): string; - get_tenantAppVersion(): string; - get_isAppWeb(): boolean; - get_webLogoUrl(): string; - get_webLanguage(): number; - get_currentLanguage(): number; - get_pageItemId(): number; - get_pageListId(): string; - get_webPermMasks(): { High: number; Low: number; }; - get_currentCultureName(): string; - get_currentUICultureName(): string; - get_clientServerTimeDelta(): number; - get_userLoginName(): string; - get_webTemplate(): string; + static get_clientServerTimeDelta(): number; + static get_siteServerRelativeUrl(): string; + static get_webServerRelativeUrl(): string; + static get_webAbsoluteUrl(): string; + static get_serverRequestPath(): string; + static get_siteAbsoluteUrl(): string; + static get_webTitle(): string; + static get_tenantAppVersion(): string; + static get_isAppWeb(): boolean; + static get_webLogoUrl(): string; + static get_webLanguage(): number; + static get_currentLanguage(): number; + static get_pageItemId(): number; + static get_pageListId(): string; + static get_webPermMasks(): { High: number; Low: number; }; + static get_currentCultureName(): string; + static get_currentUICultureName(): string; + static get_clientServerTimeDelta(): number; + static get_userLoginName(): string; + static get_webTemplate(): string; + static get_pagePersonalizationScope(): string; + static get_webPermMasks(): SP.ContextPermissions; } - - interface PageContextInfoInstance { - get_pagePersonalizationScope(): string; - } - class ContextPermissions { has(perm: number): boolean; hasPermissions(high: number, low: number): boolean; From 81089459ca8d9791e469fe0e51fbb75c70ce28b0 Mon Sep 17 00:00:00 2001 From: "Amir.Tugi@Gmail.com" Date: Wed, 23 May 2018 10:59:20 +0300 Subject: [PATCH 063/236] CR Fix --- types/express-paginate/express-paginate-tests.ts | 2 +- types/express-paginate/index.d.ts | 2 +- types/express-paginate/tsconfig.json | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/express-paginate/express-paginate-tests.ts b/types/express-paginate/express-paginate-tests.ts index 20f1a0a558..ddd87ce441 100644 --- a/types/express-paginate/express-paginate-tests.ts +++ b/types/express-paginate/express-paginate-tests.ts @@ -1,4 +1,4 @@ -import * as express from 'express'; +import express from 'express'; import * as paginate from 'express-paginate'; declare function findAndCountAll(params: object): Promise<{count: number, rows: object[]}>; diff --git a/types/express-paginate/index.d.ts b/types/express-paginate/index.d.ts index b816d11b1b..638ae944ad 100644 --- a/types/express-paginate/index.d.ts +++ b/types/express-paginate/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.7 -import * as express from 'express'; +import express = require("express"); declare global { namespace Express { diff --git a/types/express-paginate/tsconfig.json b/types/express-paginate/tsconfig.json index 9370f2106b..d524beee7a 100644 --- a/types/express-paginate/tsconfig.json +++ b/types/express-paginate/tsconfig.json @@ -8,6 +8,7 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, + "esModuleInterop": true, "baseUrl": "../", "typeRoots": [ "../" From 038389633599b2235e7a510e30829dbcb47e0253 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 23 May 2018 10:02:07 +0200 Subject: [PATCH 064/236] removing duplicated method --- types/sharepoint/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/sharepoint/index.d.ts b/types/sharepoint/index.d.ts index 7238e6c2b8..b05d498648 100644 --- a/types/sharepoint/index.d.ts +++ b/types/sharepoint/index.d.ts @@ -108,7 +108,6 @@ declare namespace SP { class PageContextInfo { constructor(); - static get_clientServerTimeDelta(): number; static get_siteServerRelativeUrl(): string; static get_webServerRelativeUrl(): string; static get_webAbsoluteUrl(): string; @@ -129,7 +128,6 @@ declare namespace SP { static get_userLoginName(): string; static get_webTemplate(): string; static get_pagePersonalizationScope(): string; - static get_webPermMasks(): SP.ContextPermissions; } class ContextPermissions { has(perm: number): boolean; From 66150a31df378ded046a6d9c94efbd7b93e521e9 Mon Sep 17 00:00:00 2001 From: Denis Artyuhovich Date: Tue, 22 May 2018 18:17:21 +0300 Subject: [PATCH 065/236] Add defenition for allure-js-commons --- .../allure-js-commons-tests.ts | 24 ++++ types/allure-js-commons/index.d.ts | 109 ++++++++++++++++++ types/allure-js-commons/tsconfig.json | 23 ++++ types/allure-js-commons/tslint.json | 1 + 4 files changed, 157 insertions(+) create mode 100644 types/allure-js-commons/allure-js-commons-tests.ts create mode 100644 types/allure-js-commons/index.d.ts create mode 100644 types/allure-js-commons/tsconfig.json create mode 100644 types/allure-js-commons/tslint.json diff --git a/types/allure-js-commons/allure-js-commons-tests.ts b/types/allure-js-commons/allure-js-commons-tests.ts new file mode 100644 index 0000000000..9d4dd653da --- /dev/null +++ b/types/allure-js-commons/allure-js-commons-tests.ts @@ -0,0 +1,24 @@ +import * as Allure from "allure-js-commons"; + +const shouldMakeError = new Allure("test"); // $ExpectError +const allure = new Allure(); + +allure.startSuite("suite"); +allure.startCase("case"); +allure.startCase("case", 123456789); + +allure.endCase("passed"); +allure.endCase("pending"); +allure.endCase("skipped"); +allure.endCase("failed"); +allure.endCase("broken", 1232131232); +allure.endCase("error"); // $ExpectError + +allure.startStep("error"); +allure.endStep("error"); // $ExpectError + +allure.setDescription("description"); +allure.addAttachment("image", {}, "image/jpeg"); +allure.pendingCase("pending"); + +allure.endSuite(); diff --git a/types/allure-js-commons/index.d.ts b/types/allure-js-commons/index.d.ts new file mode 100644 index 0000000000..6331423d1e --- /dev/null +++ b/types/allure-js-commons/index.d.ts @@ -0,0 +1,109 @@ +// Type definitions for allure-js-commons 0.0 +// Project: https://github.com/allure-framework/allure-js-commons +// Definitions by: Denis Artyuhovich +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +declare class Allure { + constructor(); + + setOptions(options: Allure.Options): void; + + getCurrentSuite(): Allure.Suite; + + getCurrentTest(): Allure.Test; + + startSuite(suiteName: string, timestamp?: number): void; + + endSuite(timestamp?: number): void; + + startCase(testName: string, timestamp?: number): void; + + endCase(status: Allure.Status, err?: {}, timestamp?: number): void; + + startStep(stepName: string, timestamp?: number): void; + + endStep(status: Allure.Status, timestamp?: number): void; + + setDescription(description: string, timestamp?: number): void; + + addAttachment(attachmentName: string, buffer: any, type: string): void; + + pendingCase(testName: string, timestamp?: number): void; +} + +export = Allure; +export as namespace Allure; +declare namespace Allure { + interface Options { + targetDir: string; + } + + type Status = "passed" | "pending" | "skipped" | "failed" | "broken"; + + enum TYPE { + TEXT = "text", + HTML = "html", + MARKDOWN = "markdown" + } + + class Suite { + constructor(name: string, timestamp?: number); + + end(timestamp?: number): void; + + hasTests(): boolean; + + addTest(test: Test): boolean; + + toXML(): string; + } + + class Test { + constructor(name: string, timestamp?: number); + + setDescription(description: string, type: TYPE): void; + + addLabel(name: string, value: string): void; + + addParameter(kind: any, name: string, value: string): void; + + addStep(step: Step): void; + + addAttachment(attachment: Attachment): void; + + end(status: Status, error: Error, timestamp?: number): void; + + toXML(): string; + } + + class Description { + constructor(value: string, type: TYPE); + + toXML(): string; + } + + class Step { + constructor(name: string, timestamp?: number); + + addStep(step: Step): void; + + addAttachment(attachment: Attachment): void; + + end(status: Status, error: Error, timestamp?: number): void; + + toXML(): string; + } + + class Attachment { + constructor(title: string, source: any, size: number, mime: string); + + addStep(step: Step): void; + + addAttachment(attachment: Attachment): void; + + end(status: Status, error: Error, timestamp?: number): void; + + toXML(): string; + } +} diff --git a/types/allure-js-commons/tsconfig.json b/types/allure-js-commons/tsconfig.json new file mode 100644 index 0000000000..9355cb2e42 --- /dev/null +++ b/types/allure-js-commons/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "allure-js-commons-tests.ts" + ] +} diff --git a/types/allure-js-commons/tslint.json b/types/allure-js-commons/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/allure-js-commons/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 8157193c263947c9bdb7f012639df511cea289ce Mon Sep 17 00:00:00 2001 From: Holger Jeromin Date: Wed, 23 May 2018 15:58:57 +0200 Subject: [PATCH 066/236] fixing file.expand typing --- types/grunt/grunt-tests.ts | 12 +++++++++--- types/grunt/index.d.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/types/grunt/grunt-tests.ts b/types/grunt/grunt-tests.ts index 5dd6550582..94eb12a46f 100644 --- a/types/grunt/grunt-tests.ts +++ b/types/grunt/grunt-tests.ts @@ -1,6 +1,6 @@ -// Official code sample from +// Official code sample from // http://gruntjs.com/getting-started#an-example-gruntfile interface MyTaskData { @@ -12,7 +12,7 @@ interface MyOptions { repeat: number; } -// exports should work same as module.exports +// exports should work same as module.exports exports = (grunt: IGrunt) => { // Project configuration. @@ -126,4 +126,10 @@ exports.exports = function(grunt: IGrunt) { }); }); -}; \ No newline at end of file +}; + + +let myTest = function (grunt: IGrunt) { + grunt.file.expand(['*.ts']); + grunt.file.expand('*.ts'); +} diff --git a/types/grunt/index.d.ts b/types/grunt/index.d.ts index 34e5b7e3cb..5187e5e965 100644 --- a/types/grunt/index.d.ts +++ b/types/grunt/index.d.ts @@ -445,7 +445,7 @@ declare namespace grunt { * File paths are relative to the Gruntfile unless the current working directory is changed with * grunt.file.setBase or the --base command-line option. */ - expand(patterns: string[]): string[]; + expand(patterns: string | string[]): string[]; expand(options: IFilesConfig, patterns: string[]): string[]; /** From 5a88056e4c0c62208a813faaf6aacbe0e6438f66 Mon Sep 17 00:00:00 2001 From: Joshua Goldberg Date: Wed, 23 May 2018 16:31:17 +0200 Subject: [PATCH 067/236] Added .headless() to Firefox options --- types/selenium-webdriver/firefox.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/selenium-webdriver/firefox.d.ts b/types/selenium-webdriver/firefox.d.ts index 0c2ecdbe92..ce8a14216e 100644 --- a/types/selenium-webdriver/firefox.d.ts +++ b/types/selenium-webdriver/firefox.d.ts @@ -149,6 +149,13 @@ export class Profile { * Configuration options for the FirefoxDriver. */ export class Options { + /** + * Sets the browser to be in headless mode. + * + * @return {!Options} A self reference. + */ + headless(): Options; + /** * Sets the profile to use. The profile may be specified as a * {@link Profile} object or as the path to an existing Firefox profile to use From 6cca6281c4bc6b482e77ba34a9c11f75baf95f7f Mon Sep 17 00:00:00 2001 From: Olegs Jeremejevs Date: Wed, 23 May 2018 18:36:11 +0300 Subject: [PATCH 068/236] is-svg: Allow Buffer input --- types/is-svg/index.d.ts | 4 +++- types/is-svg/is-svg-tests.ts | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/types/is-svg/index.d.ts b/types/is-svg/index.d.ts index 21e85cd2e2..568810f94b 100644 --- a/types/is-svg/index.d.ts +++ b/types/is-svg/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + export = isSvg; -declare function isSvg(input: string): boolean; +declare function isSvg(input: string | Buffer): boolean; diff --git a/types/is-svg/is-svg-tests.ts b/types/is-svg/is-svg-tests.ts index d556a944f9..d9ccb6f3db 100644 --- a/types/is-svg/is-svg-tests.ts +++ b/types/is-svg/is-svg-tests.ts @@ -1,3 +1,7 @@ import isSvg = require('is-svg'); -const result: boolean = isSvg(''); +const dataString = ''; +const dataBuffer = Buffer.from(dataString); + +const resultString: boolean = isSvg(dataString); +const resultBuffer: boolean = isSvg(dataBuffer); From 512616ac65e48a695af085529a5705b02c5b2f38 Mon Sep 17 00:00:00 2001 From: Olegs Jeremejevs Date: Wed, 23 May 2018 18:47:33 +0300 Subject: [PATCH 069/236] is-svg: Allow falsy input --- types/is-svg/index.d.ts | 2 +- types/is-svg/is-svg-tests.ts | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/is-svg/index.d.ts b/types/is-svg/index.d.ts index 568810f94b..9e36b57b45 100644 --- a/types/is-svg/index.d.ts +++ b/types/is-svg/index.d.ts @@ -7,4 +7,4 @@ export = isSvg; -declare function isSvg(input: string | Buffer): boolean; +declare function isSvg(input?: string | Buffer | false | null): boolean; diff --git a/types/is-svg/is-svg-tests.ts b/types/is-svg/is-svg-tests.ts index d9ccb6f3db..fe68014630 100644 --- a/types/is-svg/is-svg-tests.ts +++ b/types/is-svg/is-svg-tests.ts @@ -1,7 +1,11 @@ import isSvg = require('is-svg'); -const dataString = ''; -const dataBuffer = Buffer.from(dataString); +const data = ''; +let result = false; -const resultString: boolean = isSvg(dataString); -const resultBuffer: boolean = isSvg(dataBuffer); +result = isSvg(data); +result = isSvg(Buffer.from(data)); +result = isSvg(false); +result = isSvg(null); +result = isSvg(undefined); +result = isSvg(); From 4a7b434868f8ad87e539c54266fb15c9e85f4022 Mon Sep 17 00:00:00 2001 From: Olegs Jeremejevs Date: Wed, 23 May 2018 18:54:24 +0300 Subject: [PATCH 070/236] is-svg: Bump to 3.0 --- types/is-svg/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/is-svg/index.d.ts b/types/is-svg/index.d.ts index 9e36b57b45..1fbdc486ad 100644 --- a/types/is-svg/index.d.ts +++ b/types/is-svg/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for is-svg 2.1 +// Type definitions for is-svg 3.0 // Project: https://github.com/sindresorhus/is-svg#readme // Definitions by: BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 5f80843518a77463eb23e6b5e9618e0c375f0729 Mon Sep 17 00:00:00 2001 From: Olegs Jeremejevs Date: Wed, 23 May 2018 19:07:28 +0300 Subject: [PATCH 071/236] is-svg: Export namespace --- types/is-svg/index.d.ts | 7 +++++-- types/is-svg/is-svg-tests.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/types/is-svg/index.d.ts b/types/is-svg/index.d.ts index 1fbdc486ad..54ebb84457 100644 --- a/types/is-svg/index.d.ts +++ b/types/is-svg/index.d.ts @@ -5,6 +5,9 @@ /// -export = isSvg; - declare function isSvg(input?: string | Buffer | false | null): boolean; + +// So that `import * as X` is possible +declare namespace isSvg {} + +export = isSvg; diff --git a/types/is-svg/is-svg-tests.ts b/types/is-svg/is-svg-tests.ts index fe68014630..73ba29062c 100644 --- a/types/is-svg/is-svg-tests.ts +++ b/types/is-svg/is-svg-tests.ts @@ -1,4 +1,4 @@ -import isSvg = require('is-svg'); +import * as isSvg from 'is-svg'; const data = ''; let result = false; From 969d99802b7fef695219d5600de872d57c78e12c Mon Sep 17 00:00:00 2001 From: denis Date: Wed, 23 May 2018 18:35:57 +0200 Subject: [PATCH 072/236] d3-timer Activate strictNullChecks --- types/d3-timer/index.d.ts | 4 ++-- types/d3-timer/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/d3-timer/index.d.ts b/types/d3-timer/index.d.ts index 08fee97696..34bef32aba 100644 --- a/types/d3-timer/index.d.ts +++ b/types/d3-timer/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Last module patch version validated against: 1.0.2 +// Last module patch version validated against: 1.0.7 /** * Returns the current time as defined by performance.now if available, and Date.now if not. @@ -44,7 +44,7 @@ export interface Timer { export function timer(callback: (elapsed: number) => void, delay?: number, time?: number): Timer; /** - * Immediately invoke any eligible timer callbacks + * Immediately invoke any eligible timer callbacks. */ export function timerFlush(): void; diff --git a/types/d3-timer/tsconfig.json b/types/d3-timer/tsconfig.json index f3af0c7d8e..91aaaf2092 100644 --- a/types/d3-timer/tsconfig.json +++ b/types/d3-timer/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ From 0dcddbf82ed69b17b12063f886af70e0224ca8f9 Mon Sep 17 00:00:00 2001 From: denis Date: Wed, 23 May 2018 19:06:03 +0200 Subject: [PATCH 073/236] Remove hex inherited from Color in d3-hsv --- types/d3-hsv/d3-hsv-tests.ts | 1 + types/d3-hsv/index.d.ts | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/types/d3-hsv/d3-hsv-tests.ts b/types/d3-hsv/d3-hsv-tests.ts index 780f584c7c..20cdd4f911 100644 --- a/types/d3-hsv/d3-hsv-tests.ts +++ b/types/d3-hsv/d3-hsv-tests.ts @@ -48,6 +48,7 @@ cHSV = cHSV.darker(); cHSV = cHSV.darker(0.2); displayable = cHSV.displayable(); cString = cHSV.toString(); +cString = cHSV.hex(); console.log('Channels = (h : %d, s: %d, v: %d)', cHSV.h, cHSV.s, cHSV.v); console.log('Opacity = %d', cHSV.opacity); diff --git a/types/d3-hsv/index.d.ts b/types/d3-hsv/index.d.ts index 7452dbcc2b..1728af0874 100644 --- a/types/d3-hsv/index.d.ts +++ b/types/d3-hsv/index.d.ts @@ -68,12 +68,6 @@ export interface HSVColor extends Color { * Returns the RGB equivalent of this color. */ rgb(): RGBColor; - - /** - * Returns a hexadecimal string representing this color. - * If this color is not displayable, a suitable displayable color is returned instead. For example, RGB channel values greater than 255 are clamped to 255. - */ - hex(): string; } export const hsv: HSVColorFactory; From 99f61a7bb4ce300faece749207449652c2367871 Mon Sep 17 00:00:00 2001 From: stuartlo Date: Wed, 23 May 2018 15:20:33 -0700 Subject: [PATCH 074/236] Add tests --- types/ckeditor/ckeditor-tests.ts | 824 ++++- types/ckeditor/index.d.ts | 5526 +++++++++++++++--------------- 2 files changed, 3482 insertions(+), 2868 deletions(-) diff --git a/types/ckeditor/ckeditor-tests.ts b/types/ckeditor/ckeditor-tests.ts index 21288c1f93..acc23ae096 100644 --- a/types/ckeditor/ckeditor-tests.ts +++ b/types/ckeditor/ckeditor-tests.ts @@ -35,6 +35,13 @@ function test_CKEDITOR() { CKEDITOR.replaceAll(); CKEDITOR.replaceAll('myClassName'); CKEDITOR.replaceAll((textarea, config) => false); + + var editor: CKEDITOR.editor = CKEDITOR.appendTo('append here', CKEDITOR.config, 'data'); + var editor: CKEDITOR.editor = CKEDITOR.appendTo(document.createElement('div')); + CKEDITOR.error('code'); + CKEDITOR.error('500', { moreData: true }); + CKEDITOR.warn('danger'); + CKEDITOR.warn('303', 12345); } function test_CKEDITOR_events() { @@ -83,6 +90,8 @@ function test_dom_comment() { var nativeNode = document.createComment('Example'); var comment = new CKEDITOR.dom.comment(nativeNode); var comment2 = new CKEDITOR.dom.comment('Example'); + var comment3 = new CKEDITOR.dom.comment('Example', new CKEDITOR.dom.document(document)); + var html: string = comment.getOuterHtml(); } function test_dom_document() { @@ -103,10 +112,16 @@ function test_dom_document() { 'Document contents created by code' + '' ); + var styles: CSSStyleSheet = document.appendStyleText('some styles'); + var element: CKEDITOR.dom.element = document.createElement('div'); + var element2: CKEDITOR.dom.element = document.createElement('div', { styles: { height: '1234' } }); + var element3: CKEDITOR.dom.element = document.createElement('div', { attributes: { id: '1234' } }); + var element4: CKEDITOR.dom.element = document.createElement('div', { attributes: { tabIndex: '1234' }, styles: { width: '1234' } }); } function test_dom_documentFragment() { var type = CKEDITOR.NODE_DOCUMENT_FRAGMENT; + alert(new CKEDITOR.dom.documentFragment(document.body).type === type); } function test_dom_domObject() { @@ -124,6 +139,8 @@ function test_dom_domObject() { var elementB = new CKEDITOR.dom.element(nativeElement).getPrivate().value; var element3 = new CKEDITOR.dom.element('span'); element.setCustomData('hasCustomData', true); + + var domObject = new CKEDITOR.dom.domObject(document.createElement('div')); } function test_dom_element() { @@ -156,6 +173,7 @@ function test_dom_element() { element.appendTo(CKEDITOR.document.getBody()); alert(element.getEditor().name); var first = element.getFirst(); + var first2 = element.getFirst((node: CKEDITOR.dom.node) => node.equals(document.body)); alert(element.getHtml()); alert(element.getId()); alert(element.getName()); @@ -199,6 +217,26 @@ function test_dom_element() { alert(element == CKEDITOR.dom.element.get(element)); var htmlElement = document.getElementById('myElement'); alert(CKEDITOR.dom.element.get(htmlElement).getName()); + + var dtd: CKEDITOR.dtdDefinition = element.getDtd(); + var last: CKEDITOR.dom.node = element.getLast(); + var last2: CKEDITOR.dom.node = element.getLast((node: CKEDITOR.dom.node) => node.equals(document.body)); + if (element.isBlockBoundary({ 'div': 1, 'span': 1 })) { + element.setState(1, 'hex', false); + } + + CKEDITOR.dom.element.clearMarkers({}, element, true); + var element1: CKEDITOR.dom.element = CKEDITOR.dom.element.get('div'); + var element2: CKEDITOR.dom.element = CKEDITOR.dom.element.get(document.createElement('div')); + var element3: CKEDITOR.dom.element = CKEDITOR.dom.element.get(element2); + var markedElement: CKEDITOR.dom.element = CKEDITOR.dom.element.setMarker({}, element, 'key', 0); +} + +function test_dom_elementPath() { + var path: CKEDITOR.dom.elementPath = new CKEDITOR.dom.elementPath(CKEDITOR.dom.element.get('div')); + var path2: CKEDITOR.dom.elementPath = new CKEDITOR.dom.elementPath(CKEDITOR.dom.element.get('div'), CKEDITOR.dom.element.get(document.body)); + + var dir: 'ltr' | 'rtl' = path.direction(); } function test_dom_event() { @@ -226,8 +264,10 @@ function test_dom_event() { function test_dom_iterator() { var range = new CKEDITOR.dom.range(new CKEDITOR.dom.element('div')); var iterator = range.createIterator(); - iterator.getNextParagraph(); - iterator.getNextParagraph(); + var paragrah1: CKEDITOR.dom.element = iterator.getNextParagraph(); + var paragrah2: CKEDITOR.dom.element = iterator.getNextParagraph('div'); + alert(iterator.forceBrBreak === false); + var itRange: CKEDITOR.dom.range = iterator.range; } function test_dom_node() { @@ -255,6 +295,7 @@ function test_dom_node() { function test_dom_nodeList() { var nodeList = CKEDITOR.document.getBody().getChildren(); alert(nodeList.count()); + var nodes: CKEDITOR.dom.node[] = nodeList.toArray(); } function test_dom_range() { @@ -277,10 +318,87 @@ function test_dom_range() { alert(range.startOffset); } +function test_dom_selection() { + var element: CKEDITOR.dom.element = CKEDITOR.dom.element.get('div'); + var selection: CKEDITOR.dom.selection = new CKEDITOR.dom.selection(new CKEDITOR.dom.document(document)); + selection = new CKEDITOR.dom.selection(element); + selection = new CKEDITOR.dom.selection(selection); + + var marks: CKEDITOR.dom.bookmark[] = selection.createBookmarks('serialized'); + var marks2: CKEDITOR.dom.bookmark2[] = selection.createBookmarks2({ normalized: true }); + selection.fake(element); + selection.fake(element, true); + element = selection.getCommonAncestor(); + var domSel: Selection = selection.getNative(); + var ranges: CKEDITOR.dom.range[] = selection.getRanges(); + ranges = selection.getRanges(true); + element = selection.getSelectedElement(); + var text: string = selection.getSelectedText(); + element = selection.getStartElement(); + + var type: number = selection.getType(); + + var isSomething: boolean = selection.isCollapsed(); + isSomething = selection.isHidden(); + isSomething = selection.isInTable(); + isSomething = selection.isInTable(false); + + selection.lock(); + selection.removeAllRanges(); + selection.reset(); + selection.removeAllRanges(); + selection.reset(); + selection.scrollIntoView(); + selection = selection.selectBookmarks(marks); + selection = selection.selectBookmarks(marks2); + selection.selectElement(element); + selection.selectRanges(ranges); + selection.unlock(false); +} + +function test_dom_walker() { + var element: CKEDITOR.dom.element = CKEDITOR.dom.element.get('div'); + var range: CKEDITOR.dom.range = new CKEDITOR.dom.range(element); + + var walker: CKEDITOR.dom.walker = new CKEDITOR.dom.walker(range); + + var isSomething: boolean = walker.checkBackward(); + isSomething = walker.checkForward(); + walker.end(); + + var node: CKEDITOR.dom.node = walker.lastBackward(); + node = walker.lastForward(); + node = walker.next(); + node = walker.previous(); + walker.reset(); + + isSomething = CKEDITOR.dom.walker.blockBoundary({ 'div': 1 })(node); + isSomething = CKEDITOR.dom.walker.bogus()(node); + isSomething = CKEDITOR.dom.walker.bogus(isSomething)(node); + isSomething = CKEDITOR.dom.walker.bookmark()(node); + isSomething = CKEDITOR.dom.walker.bookmark(true)(node); + isSomething = CKEDITOR.dom.walker.bookmark(true, false)(node); + isSomething = CKEDITOR.dom.walker.editable()(node); + isSomething = CKEDITOR.dom.walker.editable(isSomething)(node); + isSomething = CKEDITOR.dom.walker.empty()(node); + isSomething = CKEDITOR.dom.walker.empty(true)(node); + isSomething = CKEDITOR.dom.walker.ignored()(node); + isSomething = CKEDITOR.dom.walker.ignored(true)(node); + isSomething = CKEDITOR.dom.walker.listItemBoundary()(node); + isSomething = CKEDITOR.dom.walker.nodeType(0)(node); + isSomething = CKEDITOR.dom.walker.nodeType(1, true)(node); + isSomething = CKEDITOR.dom.walker.temp()(node); + isSomething = CKEDITOR.dom.walker.temp(isSomething)(node); + isSomething = CKEDITOR.dom.walker.whitespaces()(node); + isSomething = CKEDITOR.dom.walker.whitespaces(isSomething)(node); +} + function test_dom_text() { var nativeNode = document.createTextNode('Example'); var text = new CKEDITOR.dom.text(nativeNode); var text2 = new CKEDITOR.dom.text('Example'); + text.substring(1, 2); + text.substring(1); } function test_dom_window() { @@ -292,6 +410,545 @@ function test_dom_window() { var size = win.getViewPaneSize(); alert(size.width); alert(size.height); + + var frame: CKEDITOR.dom.element = win.getFrame(); + win.focus(); +} + +function test_ajax() { + var req: string = CKEDITOR.ajax.load('https://ckeditor.com/ckeditor-4/'); + req = CKEDITOR.ajax.load('https://ckeditor.com/ckeditor-4/', (data: any) => console.log(data)); + + var xml: CKEDITOR.xml = CKEDITOR.ajax.loadXml('https://ckeditor.com/ckeditor-4/'); + xml = CKEDITOR.ajax.loadXml('https://ckeditor.com/ckeditor-4/', (data: any) => console.log(data)); + + CKEDITOR.ajax.post('https://ckeditor.com/ckeditor-4/', {}); + CKEDITOR.ajax.post('https://ckeditor.com/ckeditor-4/', {}, 'html'); + CKEDITOR.ajax.post('https://ckeditor.com/ckeditor-4/', {}, 'text', (data: any) => console.log(data)); +} + +function test_dataProcessor() { + var processor: CKEDITOR.dataProcessor; + processor.toDataFormat('html', 'fix'); + processor.toHtml('data'); + processor.toHtml('data', 'fix'); +} + +function test_dialog() { + var dialog: CKEDITOR.dialog = new CKEDITOR.dialog(CKEDITOR.instances[0], 'dialog'); + + var element: CKEDITOR.dom.element = CKEDITOR.dom.element.get('div'); + dialog.addFocusable(element); + dialog.addFocusable(element, 13); + dialog.addPage({ some: true, object: false }); + var ret = dialog.click('1234'); + dialog.commitContent(); + dialog.disableButton('some button'); + dialog.enableButton('4321'); + dialog = dialog.foreach(() => console.log('hey')); + + var button: CKEDITOR.ui.dialog.button = dialog.getButton('button1'); + var uiEl: CKEDITOR.ui.dialog.uiElement = dialog.getContentElement('page1', 'element1'); + element = dialog.getElement(); + var str: string = dialog.getName(); + var numb: number = dialog.getPageCount(); + var editor: CKEDITOR.editor = dialog.getParentEditor(); + var obj: { [key: string]: any } = dialog.getPosition(); + element = dialog.getSelectedElement(); + obj = dialog.getSize(); + obj = dialog.getValueOf('page1', 'ele1'); + dialog.hide(); + dialog.hidePage('1234'); + dialog.layout(); + dialog.move(1, 2, true); + dialog = dialog.reset(); + dialog.resize(numb, numb); + dialog.selectPage('1'); + dialog.setState(4); + dialog.setValueOf('page1', 'ele1', false); + dialog.setupContent(); + dialog.show(); + dialog.showPage('1234'); + dialog.updateStyle(); + + CKEDITOR.dialog.add( 'abbrDialog', this.path + 'dialogs/abbr.js' ); + CKEDITOR.dialog.add( 'abbrDialog', function ( editor: CKEDITOR.editor ) { + return { + title: 'Abbreviation Properties', + minWidth: 400, + minHeight: 200, + onLoad: () => {}, + onOk: () => {}, + onCancel: () => {}, + onShow: () => {}, + onHide: () => {}, + contents: [ + { + id: 'tab-basic', + label: 'Basic Settings', + elements: [] + }, + { + id: 'tab-adv', + label: 'Advanced Settings', + elements: [] + } + ] + }; + }); + + CKEDITOR.dialog.addIframe('frame', 'frame', 1234, 4321); + CKEDITOR.dialog.addIframe('frame', 'frame', 1234, 4321, () => console.log('loaded')); + CKEDITOR.dialog.addIframe('frame', 'frame', 1234, 4321, () => console.log('loaded'), obj); + + CKEDITOR.dialog.addUIElement('node', () => console.log('build')); + CKEDITOR.dialog.cancelButton(); + CKEDITOR.dialog.exists('dialog1'); + CKEDITOR.dialog.exists(1234); + dialog = CKEDITOR.dialog.getCurrent(); + + var isEnabled: boolean = CKEDITOR.dialog.isTabEnabled(editor, 'dialog', 'table'); + + CKEDITOR.dialog.okButton(); +} + +function test_editable() { + var element: CKEDITOR.dom.element; + var editor: CKEDITOR.editor; + + var editable: CKEDITOR.editable = new CKEDITOR.editable(editor, element); + editable = new CKEDITOR.editable(editor, document.createElement('div')); + + editable.attachClass('class'); + editable.attachListener(editable, 'event', (evt: CKEDITOR.eventInfo) => console.log('listen')).removeListener(); + editable.attachListener(new CKEDITOR.event(), 'event', (evt: CKEDITOR.eventInfo) => console.log('listen')).removeListener(); + editable.attachListener(new CKEDITOR.event(), 'event', (evt: CKEDITOR.eventInfo) => console.log('listen'), { scope: 'object' }).removeListener(); + editable.attachListener(editable, 'event', (evt: CKEDITOR.eventInfo) => console.log('listen'), { scope: 'object' }, 'data').removeListener(); + editable.attachListener(editable, 'event', (evt: CKEDITOR.eventInfo) => console.log('listen'), { scope: 'object' }, 'data', 1).removeListener(); + + editable.changeAttr('attr', 'val'); + editable.detach(); + + var range: CKEDITOR.dom.range; + editable.insertElement(element); + editable.insertElement(element, range); + editable.insertHtml('data'); + editable.insertHtml('data', 'mode'); + editable.insertHtml('data', 'mode', range); + editable.insertText(new CKEDITOR.dom.text('text')); + + var inline: boolean = editable.isInline(); + editable.setReadOnly(inline); +} + +function test_fileTools() { + var editor: CKEDITOR.editor; + var def: CKEDITOR.fileTools.uploadWidgetDefinition; + var loader: CKEDITOR.fileTools.fileLoader; + var blob: Blob; + var element: CKEDITOR.dom.element; + + CKEDITOR.fileTools.addUploadWidget(editor, 'editor', def); + CKEDITOR.fileTools.bindNotification(editor, loader); + var url: string = CKEDITOR.fileTools.getUploadUrl({ some: 'object' }); + url = CKEDITOR.fileTools.getUploadUrl({ some: 'object' }, 'type'); + + var supported = CKEDITOR.fileTools.isTypeSupported(blob, /regex/); + CKEDITOR.fileTools.markElement(element, 'name', 45); +} + +function test_fileTools_fileLoader() { + var editor: CKEDITOR.editor; + var def: CKEDITOR.fileTools.uploadWidgetDefinition; + var blob: Blob; + var element: CKEDITOR.dom.element; + + var loader: CKEDITOR.fileTools.fileLoader = new CKEDITOR.fileTools.fileLoader(editor, 'data'); + loader = new CKEDITOR.fileTools.fileLoader(editor, blob); + loader = new CKEDITOR.fileTools.fileLoader(editor, blob, 'name'); + + loader.abort(); + var finished: boolean = loader.isFinished(); + loader.load(); + loader.loadAndUpload('url'); + loader.loadAndUpload('url', { someHeader: '1234' }); + + loader.update(); + loader.upload('url'); + loader.upload('url', { someHeader: '1234' }); +} + +function test_fileTools_uploadRepository() { + var editor: CKEDITOR.editor; + var blob: Blob; + var repo: CKEDITOR.fileTools.uploadRepository = new CKEDITOR.fileTools.uploadRepository(editor); + + var loader: CKEDITOR.fileTools.fileLoader = repo.create('data', 'name'); + loader = repo.create(blob, 'name', 'type'); + + var fin: boolean = loader.isFinished(); +} + +function test_filter() { + var editor: CKEDITOR.editor; + var style: CKEDITOR.style; + + var filter: CKEDITOR.filter = new CKEDITOR.filter(editor); + filter = new CKEDITOR.filter('rule'); + filter = new CKEDITOR.filter(style); + filter = new CKEDITOR.filter([ style, 'rule', [ style, 'rule' ] ]); + filter = CKEDITOR.filter.instances['1234']; + + filter.addContentForms([ { form: true } ]); + filter.addElementCallback((el: CKEDITOR.htmlParser.element) => 4); + filter.addFeature({ allowedContent: style }); + filter.addTransformations([ [ 'transform1', { right: (element: CKEDITOR.htmlParser.element, tools: string | CKEDITOR.filter.transformationTools) => true } ] ]); + + var allowed: boolean = filter.allow(style); + allowed = filter.allow([style], 'name'); + allowed = filter.allow('rule', 'name', false); + + var apply: boolean = filter.applyTo(CKEDITOR.htmlParser.fragment.fromHtml('string'), true, false, 1); + apply = filter.applyTo(new CKEDITOR.htmlParser.element('name', null), true, false, 1); + + var checked: boolean = filter.check(style); + checked = filter.check('rule', true); + checked = filter.check(style, false, true); + + checked = filter.checkFeature({ allowedContent: style }); + + filter = filter.clone(); + filter.destroy(); + filter.disable(); + + filter.disallow(filter.disallowedContent); + var mode: number = filter.getAllowedEnterMode(1); + mode = filter.getAllowedEnterMode(1, false); +} + +function test_focusManager() { + var textarea = document.createElement('textarea'); + var instance = CKEDITOR.replace(textarea); + var element = CKEDITOR.document.getById('myElement'); + + instance.focusManager.focus(); + instance.focusManager.focus(element); + instance.focusManager.lock(); + instance.focusManager.unlock(); + instance.focusManager.blur(); + instance.focusManager.blur(true); + instance.focusManager.add(element, true); + instance.focusManager.remove(element); + + var focusManager = new CKEDITOR.focusManager(CKEDITOR.instances[0]); + var object: CKEDITOR.dom.domObject = focusManager.currentActive; + var bool: boolean = focusManager.hasFocus; +} + + +function test_htmlParser_basicWriter() { + var writer = new CKEDITOR.htmlParser.basicWriter(); + writer.attribute('class', 'MyClass'); + writer.closeTag('p'); + writer.comment('hello'); + alert(writer.getHtml(true)); // '

Hello

' + writer.openTag('p', {}); + writer.openTagClose('p', false); + writer.reset(); + writer.text('Hello'); + writer.write('data'); +} + +function test_htmlParser_cdata() { + var cdata: CKEDITOR.htmlParser.cdata = new CKEDITOR.htmlParser.cdata('hey'); + cdata.writeHtml(new CKEDITOR.htmlParser.basicWriter()); +} + +function test_htmlParser_comment() { + var filter: CKEDITOR.htmlParser.filter; + var comment: CKEDITOR.htmlParser.comment = new CKEDITOR.htmlParser.comment('hey'); + var filtered: boolean = comment.filter(filter); + comment.writeHtml(new CKEDITOR.htmlParser.basicWriter()); + comment.writeHtml(new CKEDITOR.htmlParser.basicWriter(), filter); +} + +function test_htmlParser_cssStyle() { + var element: CKEDITOR.htmlParser.element; + + var style: CKEDITOR.htmlParser.cssStyle = new CKEDITOR.htmlParser.cssStyle(element); + style = new CKEDITOR.htmlParser.cssStyle('styles'); + + style.populate(element); + style.populate(new CKEDITOR.dom.element('div')); + style.populate({ 'width': 1 }); +} + +function test_htmlParser_element() { + var element: CKEDITOR.htmlParser.element = new CKEDITOR.htmlParser.element('el', { 'id': '1'}); + + var node: CKEDITOR.htmlParser.node; + element.add(node); + element.add(node, 5); + element.addClass('class'); + element = element.clone(); + + var filter: CKEDITOR.htmlParser.filter; + var filtered: boolean = element.filter(filter); + element.filterChildren(filter); + + var nodes: CKEDITOR.htmlParser.node[] = element.find('*'); + nodes = element.find((el: CKEDITOR.htmlParser.node) => false, true); + + element.forEach((el: CKEDITOR.htmlParser.node) => console.log('node')); + element.forEach((el: CKEDITOR.htmlParser.node) => console.log('node'), 1); + element.forEach((el: CKEDITOR.htmlParser.node) => false, 2, true); + + var node: CKEDITOR.htmlParser.node = element.getFirst('*'); + node = element.getFirst({ 'id': '1' }); + node = element.getFirst((el: CKEDITOR.htmlParser.node) => true); + + var html: string = element.getHtml(); + html = element.getOuterHtml(); + + var hasClass: boolean = element.hasClass('class'); + element.removeClass('class'); + element.replaceWithChildren(); + element.setHtml('html'); + var el2: CKEDITOR.htmlParser.element = element.split(1); + + element.writeChildrenHtml(new CKEDITOR.htmlParser.basicWriter()); + element.writeChildrenHtml(new CKEDITOR.htmlParser.basicWriter(), filter); + + element.writeHtml(new CKEDITOR.htmlParser.basicWriter()); + element.writeHtml(new CKEDITOR.htmlParser.basicWriter(), filter); +} + +function test_htmlParser_filter() { + var filter: CKEDITOR.htmlParser.filter = new CKEDITOR.htmlParser.filter({ elementNames: [ 'div' ] }); + filter = new CKEDITOR.htmlParser.filter(); + + filter.addRules({ text: 'text' }); + filter.addRules({ attributes: { 'id': '1234' }}, 1); + filter.addRules({ comment: 'hey', text: 'text' }, { priority: 1 }); + filter.addRules({ root: document.body }, { applyToAll: false }); + + var node: CKEDITOR.htmlParser.node; + filter.applyTo(node); +} + + +function test_htmlParser_filterRulesGroup() { + var rules: CKEDITOR.htmlParser.filterRulesGroup = new CKEDITOR.htmlParser.filterRulesGroup(); + + rules.add([ 'some', 'rule' ], 1, { applyToAll: false, excludeNestedEditable: true }); + + rules.addMany([ (value: CKEDITOR.htmlParser.node | CKEDITOR.htmlParser.fragment | string) => false, [ 'some', 'rule' ] ], 1, { applyToAll: false }); + + var nodeFragOrString: CKEDITOR.htmlParser.node | CKEDITOR.htmlParser.fragment | string; + nodeFragOrString = rules.exec(nodeFragOrString); + + var str: string; + str = rules.execOnName(str); + + var idx: number = rules.findIndex(1); +} + +function test_htmlParser_fragment() { + var frag: CKEDITOR.htmlParser.fragment = new CKEDITOR.htmlParser.fragment(); + + var node: CKEDITOR.htmlParser.node; + frag.add(node); + frag.add(node, 1); + + var filter: CKEDITOR.htmlParser.filter; + frag.filter(filter); + frag.filterChildren(filter); + frag.filterChildren(filter, true); + frag.forEach((node: CKEDITOR.htmlParser.node) => console.log('node')); + frag.forEach((node: CKEDITOR.htmlParser.node) => false, 1); + frag.forEach((node: CKEDITOR.htmlParser.node) => false, 2, true); + + frag.writeChildrenHtml(new CKEDITOR.htmlParser.basicWriter()); + frag.writeChildrenHtml(new CKEDITOR.htmlParser.basicWriter(), filter); + + frag.writeHtml(new CKEDITOR.htmlParser.basicWriter()); + frag.writeHtml(new CKEDITOR.htmlParser.basicWriter(), filter); + + frag = CKEDITOR.htmlParser.fragment.fromBBCode('code'); + + var fragOrEl: CKEDITOR.htmlParser.fragment | CKEDITOR.htmlParser.element = CKEDITOR.htmlParser.fragment.fromHtml('html'); + fragOrEl = CKEDITOR.htmlParser.fragment.fromHtml('html', 'parent'); + fragOrEl = CKEDITOR.htmlParser.fragment.fromHtml('html', 'parent', 'fix'); + fragOrEl = CKEDITOR.htmlParser.fragment.fromHtml('html', new CKEDITOR.htmlParser.element('name', null), true); +} + +function test_htmlParser_node() { + var node: CKEDITOR.htmlParser.node = new CKEDITOR.htmlParser.node(); + + var el: CKEDITOR.htmlParser.element = node.getAscendant('condition'); + el = node.getAscendant({ 'id': '1234' }); + el = node.getAscendant((node: CKEDITOR.htmlParser.element) => false); + + var idx: number = node.getIndex(); + node.insertAfter(node); + node.insertBefore(node); + node.remove(); + node.replaceWith(node); + el = node.wrapWith(el); + +} + +function test_htmlParser_text() { + var text: CKEDITOR.htmlParser.text = new CKEDITOR.htmlParser.text('text'); + var filtered: boolean = text.filter(new CKEDITOR.htmlParser.filter()); + text.writeHtml(new CKEDITOR.htmlParser.basicWriter()); + text.writeHtml(new CKEDITOR.htmlParser.basicWriter(), new CKEDITOR.htmlParser.filter()); +} + +function test_htmlWriter() { + var writer = new CKEDITOR.htmlWriter(); + writer.openTag('p', {}); + writer.attribute('class', 'MyClass'); + writer.openTagClose('p', false); + writer.text('Hello'); + writer.closeTag('p'); + alert(writer.getHtml(true)); // '

Hello

' + + writer.indentationChars = '\t'; + writer.lineBreakChars = '\r\n'; + writer.selfClosingEnd = '>'; + writer.indentation(); + writer.lineBreak(); + writer.setRules('img', {breakBeforeOpen: true, breakAfterOpen: true}); +} + +function test_htmlParser() { + var html = '
text
'; + var fragment = CKEDITOR.htmlParser.fragment.fromHtml(html); + fragment.forEach(function(node) { + if (node instanceof CKEDITOR.htmlParser.element) { + node.forEach(function(node) { + console.log(node); + }); + } + }, CKEDITOR.NODE_ELEMENT, true); +} + +function test_keystrokeHandler() { + var handler: CKEDITOR.keystrokeHandler = new CKEDITOR.keystrokeHandler(CKEDITOR.instances[0]); + handler.attach(new CKEDITOR.dom.domObject(document.body)); +} + +function test_lang() { + var lang: string = CKEDITOR.lang.detect('en'); + lang = CKEDITOR.lang.detect('zh', 'sw'); + + CKEDITOR.lang.load('tk', 'pr', (code: string, entries: any) => console.log('loaded')); +} + +function test_loader() { + CKEDITOR.loader.load('script'); + CKEDITOR.loader.load('script', true); + + CKEDITOR.loader.loadPending(); +} + +function test_menu() { + var menu: CKEDITOR.menu = new CKEDITOR.menu(); + + menu.add({ anything: true }); + menu.addListener((startElement: CKEDITOR.dom.element, selection: CKEDITOR.dom.selection, path: CKEDITOR.dom.elementPath) => 'return'); + var { item, element } = menu.findItemByCommandName('command'); + menu.hide(); + menu.hide(false); + menu.removeAll(); + menu.show(new CKEDITOR.dom.element('div')); + menu.show(new CKEDITOR.dom.element('div'), 1); + menu.show(new CKEDITOR.dom.element('div'), 1, 2); + menu.show(new CKEDITOR.dom.element('div'), 1, 2, 3); +} + +function test_plugins() { + CKEDITOR.plugins.add( 'abbr', { + init: function( editor: CKEDITOR.editor ) { + // empty logic + } + }); + + console.log(CKEDITOR.plugins.registered['abbr']); +} + +function test_resourceManager() { + var manager: CKEDITOR.resourceManager = new CKEDITOR.resourceManager('path', 'name'); + + manager.add('name'); + manager.add('name', { hidpi: true }); + manager.addExternal('names', 'path'); + manager.addExternal('names', 'path', 'name'); + + var def: CKEDITOR.pluginDefinition = manager.get('name'); + var path: string = manager.getFilePath('path'); + path = manager.getPath('path'); + + manager.load('name', (loaded: string[]) => console.log('hey')); + manager.load([ 'name' ], (loaded: string[]) => console.log('hey'), manager); +} + +function test_scriptLoader() { + CKEDITOR.scriptLoader.load('url', (succeededUrls: boolean | string[], failedUrls: string[]) => console.log('loaded')); + CKEDITOR.scriptLoader.load([ 'url' ], (succeededUrls: boolean | string[], failedUrls: string[]) => console.log('loaded'), null); + CKEDITOR.scriptLoader.load([ 'url' ], (succeededUrls: boolean | string[], failedUrls: string[]) => console.log('loaded'), null, true); + CKEDITOR.scriptLoader.queue('url', (succeeded: boolean) => console.log('loaded')); +} + +function test_skin() { + CKEDITOR.skin.addIcon('name', 'path'); + CKEDITOR.skin.addIcon('name', 'path', 1); + CKEDITOR.skin.addIcon('name', 'path', 1, 'small'); + + CKEDITOR.skin.chameleon('editor', 'part'); + + var style: any = CKEDITOR.skin.getIconStyle('name'); + style = CKEDITOR.skin.getIconStyle('name', true); + style = CKEDITOR.skin.getIconStyle('name', true, 1); + style = CKEDITOR.skin.getIconStyle('name', true, 1, 'large'); + + var path: any = CKEDITOR.skin.getPath('part'); + + CKEDITOR.skin.loadPart('part', () => console.log('load')); + + var path2: string = CKEDITOR.skin.path(); +} + +function test_style() { + var style: CKEDITOR.style = new CKEDITOR.style({ element: 'div' }, { 'key': 'value '}); + style.apply(CKEDITOR.instances[0]); + + var el: CKEDITOR.dom.element; + style.applyToObject(el, CKEDITOR.instances[0]); + + var range: Range; + style.applyToRange(range, CKEDITOR.instances[0]); + + var str: string = style.buildPreview(); + str = style.buildPreview('label'); + + var path: CKEDITOR.dom.elementPath; + var bool: boolean = style.checkActive(path, CKEDITOR.instances[0]); + + var filter: CKEDITOR.filter; + bool = style.checkApplicable(path, CKEDITOR.instances[0], filter); + + bool = style.checkElementMatch(el, true, CKEDITOR.instances[0]); + bool = style.checkElementRemovable(el, false, CKEDITOR.instances[0]); + + var def: CKEDITOR.style.definition = style.getDefintion(); + style.remove(CKEDITOR.instances[0]); + style.removeFromRange(range, CKEDITOR.instances[0]); + + var rules: CKEDITOR.filter.allowedContentRules; + rules = style.toAllowedContentRules(); + rules = style.toAllowedContentRules(CKEDITOR.instances[0]); } function test_adding_command_and_buttons() { @@ -320,47 +977,6 @@ function test_adding_command_and_buttons() { }); } -function test_adding_dialog_by_path() { - CKEDITOR.dialog.add( 'abbrDialog', this.path + 'dialogs/abbr.js' ); -} - -function test_adding_dialog_by_definition() { - CKEDITOR.dialog.add( 'abbrDialog', function ( editor: CKEDITOR.editor ) { - return { - title: 'Abbreviation Properties', - minWidth: 400, - minHeight: 200, - onLoad: () => {}, - onOk: () => {}, - onCancel: () => {}, - onShow: () => {}, - onHide: () => {}, - contents: [ - { - id: 'tab-basic', - label: 'Basic Settings', - elements: [] - }, - { - id: 'tab-adv', - label: 'Advanced Settings', - elements: [] - } - ] - }; - }); -} - -function test_plugins() { - CKEDITOR.plugins.add( 'abbr', { - init: function( editor: CKEDITOR.editor ) { - // empty logic - } - }); - - console.log(CKEDITOR.plugins.registered['abbr']); -} - function test_adding_widget() { function wrapper(editor: CKEDITOR.editor) { editor.widgets.add("widgetty", { @@ -374,52 +990,6 @@ function test_adding_widget() { } } -function test_focusManager() { - var textarea = document.createElement('textarea'); - var instance = CKEDITOR.replace(textarea); - var element = CKEDITOR.document.getById('myElement'); - - instance.focusManager.focus(); - instance.focusManager.focus(element); - instance.focusManager.lock(); - instance.focusManager.unlock(); - instance.focusManager.blur(); - instance.focusManager.blur(true); - instance.focusManager.add(element, true); - instance.focusManager.remove(element); - - var focusManager = new CKEDITOR.focusManager(instance); - var object: CKEDITOR.dom.domObject = focusManager.currentActive; - var bool: boolean = focusManager.hasFocus; -} - -function test_basicWriter() { - var writer = new CKEDITOR.htmlParser.basicWriter(); - writer.openTag('p', {}); - writer.attribute('class', 'MyClass'); - writer.openTagClose('p', false); - writer.text('Hello'); - writer.closeTag('p'); - alert(writer.getHtml(true)); // '

Hello

' -} - -function test_htmlWriter() { - var writer = new CKEDITOR.htmlWriter(); - writer.openTag('p', {}); - writer.attribute('class', 'MyClass'); - writer.openTagClose('p', false); - writer.text('Hello'); - writer.closeTag('p'); - alert(writer.getHtml(true)); // '

Hello

' - - writer.indentationChars = '\t'; - writer.lineBreakChars = '\r\n'; - writer.selfClosingEnd = '>'; - writer.indentation(); - writer.lineBreak(); - writer.setRules('img', {breakBeforeOpen: true, breakAfterOpen: true}); -} - function test_sharedSpace() { CKEDITOR.inline('content', { removePlugins: 'maximize,resize', @@ -570,31 +1140,75 @@ function test_selection() { } function test_tools() { - var obj = { key: 'value' }; + var obj: { [key: string]: any } = { key: 'value' }; + + CKEDITOR.tools.addFunction(console.log); + CKEDITOR.tools.addFunction(console.log, obj); + var bool = CKEDITOR.tools.arrayCompare([ 1 ], [ 2, 3 ]); CKEDITOR.tools.clone(obj); CKEDITOR.tools.copy(obj); - CKEDITOR.tools.prototypedCopy(obj); - + obj = CKEDITOR.tools.createClass(obj); + var str = CKEDITOR.tools.cssStyleToDomStyle('style'); + var prefixes: { [cssClass: string]: string | number } = CKEDITOR.tools.cssVendorPrefix('prop', 'val'); + prefixes = CKEDITOR.tools.cssVendorPrefix('prop', 'val', true); + var fn: (param: any) => boolean + fn = CKEDITOR.tools.defer<(param: any) => boolean>(fn); + CKEDITOR.tools.enableHtml5Elements(document); + CKEDITOR.tools.enableHtml5Elements(document.createDocumentFragment(), true); + str = CKEDITOR.tools.escapeCss('css'); + var { input, reset } = CKEDITOR.tools.eventsBuffer(1, console.log, obj); + obj = CKEDITOR.tools.extend(obj, obj, true, obj); + bool = CKEDITOR.tools.fixDomain(); + str = CKEDITOR.tools.genKey(str); + str = CKEDITOR.tools.getCookie(str); + str = CKEDITOR.tools.getCsrfToken(); + var numb: number = CKEDITOR.tools.getIndex(['string', 'array'], (element: string) => false); + bool = CKEDITOR.tools.getMouseButton(new CKEDITOR.dom.event(document.createEvent(null))); + str = CKEDITOR.tools.getNextId(); + numb = CKEDITOR.tools.getNextNumber(); + str = CKEDITOR.tools.getUniqueId(); + str = CKEDITOR.tools.htmlDecode(str); + str = CKEDITOR.tools.htmlDecodeAttr(str); + str = CKEDITOR.tools.htmlEncode(str); + str = CKEDITOR.tools.htmlEncodeAttr(str); + numb = CKEDITOR.tools.indexOf(['string', 'array'], 'string'); + numb = CKEDITOR.tools.indexOf([true, false], (val: boolean) => false); console.log(CKEDITOR.tools.isArray([1])); // true console.log(CKEDITOR.tools.isArray(obj)); // false console.log(CKEDITOR.tools.isArray(null)); // false console.log(CKEDITOR.tools.isArray(undefined)); // false - + bool = CKEDITOR.tools.isEmpty(obj); + var ret1: { display: string[], aria: string[] } = CKEDITOR.tools.keystrokeToArray(obj, 1); + var ret2: { display: string, aria: string } = CKEDITOR.tools.keystrokeToString(obj, 1); + str = CKEDITOR.tools.ltrim(str); + str = CKEDITOR.tools.normalizeCssText(str, bool); + str = CKEDITOR.tools.normalizeHex(str); + bool = CKEDITOR.tools.objectCompare(obj, obj); + bool = CKEDITOR.tools.objectCompare(obj, obj, true); + var strArr: string[] = CKEDITOR.tools.objectKeys(obj); CKEDITOR.tools.override(parseInt, function(_parseInt) { return function(value: any, radix?: number) { return _parseInt(value, radix); }; }); -} - -function test_htmlParser() { - var html = '
text
'; - var fragment = CKEDITOR.htmlParser.fragment.fromHtml(html); - fragment.forEach(function(node) { - if (node instanceof CKEDITOR.htmlParser.element) { - node.forEach(function(node) { - console.log(node); - }); - } - }, CKEDITOR.NODE_ELEMENT, true); + obj = CKEDITOR.tools.parseCssText(str); + obj = CKEDITOR.tools.parseCssText(str, bool); + obj = CKEDITOR.tools.parseCssText(str, bool, bool); + obj = CKEDITOR.tools.prototypedCopy(obj); + CKEDITOR.tools.removeFunction(1); + str = CKEDITOR.tools.repeat(str, 40); + str = CKEDITOR.tools.rtrim(str); + str = CKEDITOR.tools.search(strArr, 'string'); + str = CKEDITOR.tools.search(strArr, (el: string) => true); + CKEDITOR.tools.setCookie('name', 'value'); + numb = CKEDITOR.tools.setTimeout(console.log); + numb = CKEDITOR.tools.setTimeout(console.log, 1000); + numb = CKEDITOR.tools.setTimeout(console.log, 1000, obj); + numb = CKEDITOR.tools.setTimeout(console.log, 1000, obj, 'timeout'); + numb = CKEDITOR.tools.setTimeout(console.log, 1000, obj, 'timeout', window); + str = CKEDITOR.tools.transformPlainTextToHtml(str, 1); + str = CKEDITOR.tools.trim(str); + CKEDITOR.tools.tryThese([ console.log, console.warn ]); + str = CKEDITOR.tools.writeCssText(obj); + str = CKEDITOR.tools.writeCssText(obj, true); } diff --git a/types/ckeditor/index.d.ts b/types/ckeditor/index.d.ts index 44c40f3699..95852e9e04 100644 --- a/types/ckeditor/index.d.ts +++ b/types/ckeditor/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for CKEditor 4.9.2 +// Type definitions for CKEditor 4.9 // Project: https://ckeditor.com/ckeditor-4/ // Definitions by: Thomas Wittwer // Stuart Long @@ -7,2765 +7,2765 @@ // WORK-IN-PROGRESS: Any contribution support welcomed. // See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/1827 for more informations. interface Window { - CKEDITOR_BASEPATH: string; -} - -declare namespace CKEDITOR { - - // Config options - var disableAutoInline: boolean; - var replaceClass: string; - var skinName: string; - - // Properties - const ALT: number; - const CTRL: number; - const DATA_TRANSFER_CROSS_EDITORS: number; - const DATA_TRANSFER_EXTERNAL: number; - const DATA_TRANSFER_INTERNAL: number; - const DIALOG_RESIZE_BOTH: number; - const DIALOG_RESIZE_HEIGHT: number; - const DIALOG_RESIZE_NONE: number; - const DIALOG_RESIZE_WIDTH: number; - const DIALOG_STATE_BUSY: number; - const DIALOG_STATE_IDLE: number; - const ELEMENT_MODE_APPENDTO: number; - const ELEMENT_MODE_INLINE: number; - const ELEMENT_MODE_NONE: number; - const ELEMENT_MODE_REPLACE: number; - const END: number; - const ENLARGE_BLOCK_CONTENTS: number; - const ENLARGE_ELEMENT: number; - const ENLARGE_INLINE: number; - const ENLARGE_LIST_ITEM_CONTENTS: number; - const ENTER_BR: number; - const ENTER_DIV: number; - const ENTER_P: number; - const EVENT_PHASE_AT_TARGET: number; - const EVENT_PHASE_BUBBLING: number; - const EVENT_PHASE_CAPTURING: number; - const FILTER_SKIP_TREE: number; - const LINEUTILS_AFTER: number; - const LINEUTILS_BEFORE: number; - const LINEUTIS_INSIDE: number; - const MOUSE_BUTTON_LEFT: number; - const MOUSE_BUTTON_MIDDLE: number; - const MOUSE_BUTTON_RIGHT: number; - const NODE_COMMENT: number; - const NODE_DOCUMENT: number; - const NODE_DOCUMENT_FRAGMENT: number; - const NODE_ELEMENT: number; - const NODE_TEXT: number; - const POSITION_AFTER_END: number; - const POSITION_AFTER_START: number; - const POSITION_BEFORE_END: number; - const POSITION_BEFORE_START: number; - const POSITION_CONTAINS: number; - const POSITION_DISCONNECTED: number; - const POSITION_FOLLOWING: number; - const POSITION_IDENTICAL: number; - const POSITION_IS_CONTAINED: number; - const POSITION_PRECEDING: number; - const SELECTION_ELEMENT: number; - const SELECTION_NONE: number; - const SELECTION_TEXT: number; - const SHIFT: number; - const SHRINK_ELEMENT: number; - const SHRINK_TEXT: number; - const START: number; - const STYLE_BLOCK: string; - const STYLE_INLINE: string; - const STYLE_OBJECT: string; - const TRISTATE_DISABLED: number; - const TRISTATE_OFF: number; - const TRISTATE_ON: number; - const UI_BUTTON: string; - const UI_MENUBUTTON: string; - const UI_PANEL: string; - const UI_PANELBUTTON: string; - const UI_RICHCOMBO: string; - const UI_SEPARATOR: string; - const VERBOSITY_ERROR: number; - const VERBOSITY_WARN: number; - - var basePath: string; - var currentInstance: editor; - var document: dom.document; - var instances: { [id: string]: editor }; - var loadFullCoreTimeout: number; - var revision: string; - var rnd: number; - var status: string; - var timestamp: string; - var verbosity: number; - var version: string; - const config: config; - - // Methods - function add(editor: editor): void; - function addCss(css: string): void; - function addTemplate(name: string, source: string): template; - function appendTo(element: string | HTMLElement, config?: config, data?: string): editor; - function domReady(): void; - function editorConfig(config: config): void; - function error(errorCode: string, additionalData?: any): void; - function getCss(): string; - function getTemplate(name: string): template; - function getUrl(resource: string): string; - function inline(element: string | HTMLElement, instanceConfig?: config): editor; - function inlineAll(): void; - function loadFullCore(): void; - function replace(element: string | HTMLTextAreaElement, config?: config): editor; - function replaceAll(className?: string): void; - function replaceAll(assertionFunction: (textarea: HTMLTextAreaElement, config: config) => boolean): void; - function warn(errorCode: string, additionalData?: any): void; - - // Event interface - function capture(): void; - function define(name: string, meta: { [key: string]: any }): void; - function fire(eventName: string, data?: { [key: string]: any }, editor?: editor): any; - function fireOnce(eventName: string, data?: { [key: string]: any }, editor?: editor): any; - function hasListeners(eventName: string): boolean; - function on(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: { [key: string]: any }, listenerData?: { [key: string]: any }, priority?: number): void; - function once(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: { [key: string]: any }, listenerData?: { [key: string]: any }, priority?: number): void; - function removeAllListeners(): void; - function removeListener(eventName: string, listenerFunction: (eventInfo: eventInfo) => void): void; - - type listenerRegistration = { - removeListener: () => void; - } - - namespace dom { - - interface bookmark { - startNode: dom.node | string; - endNode: dom.node | string; - serializable: boolean; - collapsed: boolean; - } - - interface bookmark2 { - start: number[]; - end: number[]; - startOffset: number; - endOffset: number; - collapsed: boolean; - normalized: boolean; - is2: boolean; - } - - class comment extends node { - readonly type: number; - - constructor(comment: string | Node, ownerDocument?: document); - getOuterHtml(): string; - } - - class document extends domObject { - readonly $: Document; - readonly type: number; - - constructor(domDocument: { [key: string]: any }); - appendStyleSheet(cssFileUrl: string): void; - appendStyleText(cssStyleText: string): CSSStyleSheet; - createElement(name: string, attribsAndStyles?: { attributes: { [key: string]: any }; styles: { [key: string]: any }; }): element; - createText(text: string): element; - find(selector: string): nodeList; - findOne(selector: string): element; - focus(): void; - getActive(): element; - getBody(): element; - getByAddress(address: any[], normalized?: boolean): node; - getById(elementId: string): element; - getDocumentElement(): element; - getElementsByTag(tagName: string): nodeList; - getHead(): element; - getSelection(): selection; - getWindow(): window; - write(html: string): void; - } - - class documentFragment extends node { - readonly type: number; - - constructor(nodeOrDoc: { [key: string]: any }); - insertAfterNode(node: node): void; - } - - class domObject extends event { - readonly $: any; - - constructor(nativeDomObject: { [key: string]: any }); - clearCustomData(): void; - equals(object: any): boolean; - fire(eventName: string, data?: any, editor?: editor): any; - getCustomData(key: string): any; - getPrivate(): any; - getUniqueId(): number; - removeAllListeners(): void; - removeCustomData(key: string): any; - setCustomData(key: string, value: any): domObject; - } - - class element extends node { - readonly $: HTMLElement; - readonly type: number; - - constructor(element: string, ownerDocument?: document); - constructor(element: HTMLElement, ownerDocument?: document); - addClass(className: string): void; - append(node: node | string, toStart?: boolean): node; - appendBogus(force: boolean): void; - appendHtml(html: string): void; - appendText(text: string): node; - breakParent(parent: element): void; - contains(node: node): boolean; - copyAttributes(dest: element, skipAttributes: { [key: string]: string }): void; - data(name: string, value?: string | boolean): string; - disableContextMenu(): void; - find(selector: string): nodeList; - findOne(selector: string): element; - focus(defer?: boolean): void; - focusNext(ignoreChildren?: boolean, indexToUse?: number): void; - focusPrevious(ignoreChildren?: boolean, indexToUse?: number): void; - forEach(callback: (node: node) => void, type?: number, skipRoot?: boolean): void; - getAttribute(name: string): string; - getBogus(): node | boolean; - getChild(indices: number | number[]): node; - getChildCount(): number; - getChildren(): nodeList; - getClientRect(): ClientRect; - getComputedStyle(propertyName: string): string; - getDirection(useComputed: boolean): string; - getDocumentPosition(refDocument: document): position; - getDtd(): dtdDefinition; - getEditor(): editor; - getElementsByTag(tagName: string): nodeList; - getFirst(evaluator?: (node: node) => boolean): node; - getFrameDocument(): document; - getHtml(): string; - getId(): string; - getLast(evaluator?: (node: node) => boolean): node; - getName(): string; - getNameAtt(): string; - getOuterHtml(): string; - getPositionedAncestor(): element; - getSize(type: string, isBorderBox: boolean): void; - getStyle(name: string): string; - getTabIndex(): number; - getText(): string; - getValue(): string; - getWindow(): window; - hasAttributes(): boolean; - hasAttribute(name: string): boolean; - hasClass(className: string): boolean; - hide(): void; - is(...name: string[]): boolean; - is(name: any): boolean; - isBlockBoundary(customNodeNames: { [tagName: string]: 1 }): boolean; - isEditable(textCursor?: boolean): boolean; - isEmptyInlineRemoveable(): boolean; - isIdentical(otherElement: element): boolean; - isVisible(): boolean; - mergeSiblings(inlineOnly?: boolean): void; - moveChildren(target: element, toStart?: boolean): void; - removeAttribute(name: string): void; - removeAttributes(attributes?: string[]): void; - removeClass(className: string): void; - removeStyle(name: string): void; - renameNode(newTag: string): void; - scrollIntoParent(parent: element, alignToTop: boolean, hscroll: boolean): void; - scrollIntoParent(parent: window, alignToTop: boolean, hscroll: boolean): void; - scrollIntoView(alignToTop?: boolean): void; - setAttribute(name: string, value: string): element; - setAttributes(attributesPairs: { [key: string]: string }): element; - setHtml(html: string): string; - setOpacity(opacity: number): void; - setSize(type: string, size: number, isBorderBox: boolean): void; - setState(state: number, base?: string, useAria?: boolean): void; - setStyle(name: string, value: string): element; - setStyles(stylesPair: { [key: string]: string }): element; - setText(text: string): string; - setValue(value: string): element; - show(): void; - unselectable(): void; - - //static method - static clearAllMarkers(database: any): any; - static clearMarkers(database: any, element: dom.element, removeFromDatabase: boolean): void; - static createFromHtml(html: string): element; - static get(element: string | HTMLElement | element): element; - static setMarker(database: any, element: dom.element, name: string, value: any): dom.element; - } - - class elementPath { - readonly block: element; - readonly blockLimit: element; - readonly elements: element[]; - readonly lastElement: element; - readonly root: element; - - constructor(startNode: element, root?: element); - compare(otherPath: elementPath): boolean; - contains(query: string | string[] | ((element: element) => boolean) | { [key: string]: any } | element, excludeRoot?: boolean, fromTop?: boolean): element; - direction(): 'ltr' | 'rtl'; - isContextFor(tag: string): boolean; - } - - class event { - constructor(domEvent: Event); - getKey(): number; - getKeystroke(): number; - preventDefault(stopPropagation?: boolean): void; - stopPropagation(): void; - getTarget(): node; - getPhase(): number; - getPhaseOffset(): position; - on(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: any, listenerData?: any, priority?: number): { removeListener: () => void }; - } - - class iterator { - readonly activeFilter: filter; - enforceRealBlocks: boolean; - enlargeBr: boolean; - readonly filter: filter; - forceBrBreak: boolean; - readonly range: range; - constructor(range: range); - getNextParagraph(blockTag?: string): element; - } - - class node extends domObject { - constructor(domNode: Node); - appendTo(element: element): element; - clone(includeChildren: boolean, cloneId: boolean): node; - hasPrevious(): boolean; - hasNext(): boolean; - insertAfter(node: node): node; - insertBefore(node: node): node; - insertBeforeMe(node: node): node; - getAddress(normalized?: boolean): number[]; - getAscendant(reference: string, includeSelf?: boolean): node; - getCommonAncestor(node: node): void; - getDocument(): document; - getIndex(normalized?: boolean): number; - getNext(evaluator?: (node: node) => boolean): node; - getNextSourceNode(startFromSibling: boolean, nodeType: number, guard: node | ((node: node) => boolean)): void; - getParent(allowFragmentParent?: boolean): element; - getParents(closerFirst?: boolean): node[]; - getPosition(otherNode: node): void; - getPrevious(evaluator?: (node: node) => boolean): node; - getPreviousSourceNode(startFromSibling: boolean, nodeType: number, guard: node | ((node: node) => boolean)): void; - hasAscendant(name: string, includeSelf: boolean): boolean; - remove(preserveChildren?: boolean): node; - replace(nodeToReplace: node): void; - trim(): void; - ltrim(): void; - rtrim(): void; - isReadOnly(): boolean; - } - - class nodeList { - constructor(nativeList: NodeList); - count(): number; - getItem(index: number): node; - toArray(): node[]; - } - - class range { - readonly collapsed: boolean; - readonly document: document; - readonly endContainer: element | text; - readonly endOffset: number; - readonly root: element; - readonly startContainer: element | text; - readonly startOffset: number; - - constructor(root: element | document); - checkBoundaryOfElement(element: element, checkType: number): boolean; - checkEndOfBlock(): boolean; - checkReadOnly(): boolean; - checkStartOfBlock(): boolean; - clone(cloneId?: boolean): range; - cloneContents(): documentFragment; - collapse(toStart?: boolean): boolean; - createBookmark(serializable?: boolean): bookmark; - createBookmark2(normalized?: boolean): bookmark2; - createIterator(): iterator; - deleteContents(mergeThen?: boolean): void; - endPath(): elementPath; - enlarge(unit: number, excludeBrs?: boolean): void; - extractContents(mergeThen?: boolean, cloneId?: boolean): documentFragment; - fixBlock(isStart: boolean, blockTag: string): element; - getBoundaryNodes(): { startNode: node; endNode: node; }; - getCommonAncestor(includeSelf?: boolean, ignoreTextNode?: boolean): element; - getEnclosedNode(): node; - getNextEditableNode(): element | text; - getNextNode(evaluator: (element: dom.element) => boolean, guard?: (element: dom.element) => boolean, boundary?: element): element; - getPreviousEditableNode(): element | text; - getPreviousNode(evaluator: (element: dom.element) => boolean, guard?: (element: dom.element) => boolean, boundary?: element): element; - getTouchedEndNode(): node; - getTouchedStartNode(): node; - insertNode(node: node): void; - moveToBookmark(bookmark: bookmark | bookmark2): void; - moveToClosestEditablePosition(element?: element, isMoveForward?: boolean): boolean; - moveToElementEditEnd(target: element): boolean; - moveToElementEditStart(target: element): boolean; - moveToElementEditablePosition(element: element, isMoveToEnd: boolean): boolean; - moveToPosition(node: node, position: number): void; - moveToRange(range: range): void; - optimize(): void; - optimizeBookmark(): void; - removeEmptyBlocksAtEnd(atEnd: boolean): void; - scrollIntoView(): void; - select(): selection; - selectNodeContents(node: node): void; - setEnd(endNode: node, endOffset: number): void; - setEndAfter(node: node): void; - setEndAt(node: node, position: number): void; - setEndBefore(node: node): void; - setStart(startNode: node, startOffset: number): void; - setStartAfter(node: node): void; - setStartAt(node: node, position: number): void; - setStartBefore(node: node): void; - shrink(mode: number, selectContents?: boolean, options?: boolean | shrinkOptions): void; - splitBlock(cloneId?: boolean): void; - splitElement(toSplit: element, cloneId?: boolean): element; - startPath(): elementPath; - trim(ignoreStart?: boolean, ignoreEnd?: boolean): void; - - static mergeRanges(ranges: range[]): range[]; - } - - interface shrinkOptions { - shrinkOnBlockBoundary?: boolean, - skipBogus?: boolean - } - - class rangeList { - constructor(ranges?: range | range[]); - createBokmarks(serializable?: boolean): bookmark[]; - createBookmarks2(normalized?: boolean): bookmark2[]; - createIterator(): rangeListIterator; - moveToBookmarks(bookmarks: bookmark[]): void; - } - - - interface rangeListIterator { - getNextRange(mergeConsequent?: boolean): range; - } - - // see https://docs.com/ckeditor4/latest/api/CKEDITOR_dom_selection.html - class selection { - readonly FILLING_CHAR_SEQUENCE: string; - readonly document: document; - readonly isFake: boolean; - readonly isLocked: boolean; - readonly rev: number; - readonly root: element; - - constructor(target: document | element | selection); - createBookmarks(serializable: any): bookmark[]; - createBookmarks2(normalized: any): bookmark2[]; - fake(element: element, ariaLabel?: boolean): void; - getCommonAncestor(): element; - getNative(): Selection; - getRanges(onlyEditables?: boolean): range[]; - getSelectedElement(): element; - getSelectedText(): string; - getStartElement(): element; - getType(): number; - isCollapsed(): boolean; - isHidden(): boolean; - isInTable(allowPartialSelection?: boolean): boolean; - lock(): void; - removeAllRanges(): void; - reset(): void; - scrollIntoView(): void; - selectBookmarks(bookmarks: (bookmark | bookmark2)[]): selection; - selectElement(element: element): void; - selectRanges(ranges: range[]): void; - unlock(restore: boolean): void; - } - - class text extends node { - readonly $: Text; - readonly type: number; - - constructor(text: Text | string, ownerDocument?: document); - getLength(): number; - getText(): string; - setText(text: string): void; - split(offset: number): text; - substring(indexA: number, indexB?: number): void; - } - - class walker { - evaluator: (node: node) => boolean; - guard: (node: node) => boolean; - - static validEmptyBlockContainers: { [key: string]: any }; - - constructor(range: range); - checkBackward(): boolean; - checkForward(): boolean; - end(): void; - lastBackward(): node; - lastForward(): node; - next(): node; - previous(): node; - reset(): void; - - static blockBoundary(customNodeNames: any): (node: node) => boolean; - static bogus(isReject?: boolean): (node: node) => boolean; - static bookmark(contentOnly?: boolean, isReject?: boolean): (node: node) => boolean; - static editable(isReject?: boolean): (node: node) => boolean; - static empty(isReject?: boolean): (node: node) => boolean; - static ignored(isReject?: boolean): (node: node) => boolean; - static invisible(isReject?: boolean): (node: node) => boolean; - static listItemBoundary(): (node: node) => boolean; - static nodeType(type: number, isReject?: boolean): (node: node) => boolean; - static temp(isReject?: boolean): (node: node) => boolean; - static whitespaces(isReject?: boolean): (node: node) => boolean; - } - - interface position { - x: number; - y: number; - } - - interface widthAndHeight { - width: number; - height: number; - } - - class window extends domObject { - constructor(domWindow: Window); - focus(): void; - getViewPaneSize(): widthAndHeight; - getScrollPosition(): position; - getFrame(): element; - } - } - - - namespace ajax { - function load(url: string, callback?: (data: any) => void): string; - function loadXml(url: string, callback?: (data: any) => void): xml; - function post(url: string, data: any, contentType?: string, callback?: (data: any) => void): void; - } - - - class command extends event implements commandDefinition { - fakeKeystroke: number; - previousState: number; - state: number; - uiItems: any[]; - - // Methods - constructor(editor: editor, commandDefinition: commandDefinition); - checkAllowed(noCache: boolean): boolean; - disable(): void; - enable(): void; - exec(data?: { [key: string]: any }): boolean; - refresh(editor: editor, path: dom.elementPath): void; - setState(newState: number): boolean; - toggleState(): void; - - } - - interface commandDefinition { - async?: boolean; - canUndo?: boolean; - context?: boolean; - contextSensitive?: boolean; - editorFocus?: boolean; - fakeKeystroke?: number; - modes?: { [key: string]: any }; - startDisabled?: boolean; - readOnly?: boolean; - exec(editor: editor, data?: any): boolean; - refresh?(editor: editor, path: dom.elementPath): void; - } - - // https://docs.com/ckeditor4/latest/api/CKEDITOR_config.html - interface config { - allowedContent?: boolean | filter.allowedContentRules; - autoEmbed_widget?: string | ((url: string) => string); - autoGrow_bottomSpace?: number; - autoGrow_maxHeight?: number; - autoGrow_minHeight?: number; - autoGrow_onStartup?: boolean; - autoUpdateElement?: boolean; - - baseFloatZIndex?: number; - baseHref?: string; - basicEntities?: boolean; - blockedKeystrokes?: number[]; - bodyClass?: string; - bodyId?: string; - browserContextMenuOnCtrl?: boolean; - - clipboard_defaultContentType?: 'html' | 'text'; - clipboard_notificationDuration?: number; - cloudServices_tokenUrl?: string; - cloudServices_uploadUrl?: string; - codeSnippetGeshi_url?: string; - codeSnippet_codeClass?: string; - codeSnippet_languages?: { [key: string]: any }; - coceSnippet_theme?: string; - colorButton_backStyle?: config.styleObject; - colorButton_colors?: string; - colorButton_colorsPerRow?: number; - colorButton_enableAutomatic?: boolean; - colorButton_enableMore?: boolean; - colorButton_foreStyle?: config.styleObject; - colorButton_normalizeBackground?: boolean; - contentsCss?: string | string[]; - contentsLangDirection?: string; - contentsLanguage?: string; - copyFormatting_allowRules?: string; - copyFormatting_allowedContexts?: boolean | string[]; - copyFormatting_keystrokeCopy?: number; - copyFormatting_keystrokePaste?: number; - copyFormatting_outerCursor?: boolean; - coreStyles_bold?: config.styleObject; - coreStyles_italic?: config.styleObject; - coreStyles_strike?: config.styleObject; - coreStyles_subscript?: config.styleObject; - coreStyles_superscript?: config.styleObject; - coreStyles_underline?: config.styleObject; - customConfig?: string; - - dataIndentationChars?: string; - defaultLanguage?: string; - devtools_styles?: string; - devtools_textCallback?: (editor: editor, dialog: dialog, element: dom.element, tabName: string) => string; - dialog_backgroundCoverColor?: string; - dialog_backgroundCoverOpacity?: number; - dialog_buttonsOrder?: string; - dialog_magnetDistance?: number; - dialog_noConfirmCancel?: boolean; - dialog_startupFocusTab?: boolean; - disableNativeSpellChecker?: boolean; - disableNativeTableHandles?: boolean; - disableNativeObjectResizing?: boolean; - disableNativeReadonlyStyling?: boolean; - disallowedContent?: filter.disallowedContentRules; - div_wrapTable?: boolean; - docType?: string; - - easyimage_class?: string; - easyimage_defaultStyle?: string; - easyimage_styles?: { [key: string]: any }; - easyimage_toolbar?: string[] | string; - emailProtection?: string; - embed_provider?: string; - enableTabKeyTools?: boolean; - enterMode?: number; - entities?: boolean; - entities_additional?: string; - entities_greek?: boolean; - entities_latin?: boolean; - entities_processNumerical?: boolean | string; - extraAllowedContent?: filter.allowedContentRules; - extraPlugins?: string; - - fileTools_defaultFileName?: string; - fileTools_requestHeaders?: { [key: string]: any }; - filebrowserBrowseUrl?: string; - filebrowserFlashBrowseUrl?: string; - filebrowserFlashUploadUrl?: string; - filebrowserImageBrowseLinkUrl?: string; - filebrowserImageBrowseUrl?: string; - filebrowserImageUploadUrl?: string; - filebrowserUploadMethod?: string; - filebrowserUploadUrl?: string; - filebrowserWindowFeatures?: string; - filebrowserWindowHeight?: number | string; - filebrowserWindowWidth?: number | string; - fillEmptyBlocks?: boolean | ((element: htmlParser.element) => boolean); - find_highlight?: config.styleObject; - flashAddEmbedTag?: boolean; - flashConvertOnEdit?: boolean; - flashEmbedTagOnly?: boolean; - floatSpaceDockedOffsetX?: number; - floatSpaceDockedOffsetY?: number; - floatSpacePinnedOffsetX?: number; - floatSpacePinnedOffsetY?: number; - floatSpacePreferRight?: boolean; - fontSize_defaultLabel?: string; - fontSize_sizes?: string; - fontSize_style?: config.styleObject; - font_defaultLabel?: string; - font_names?: string; - font_style?: config.styleObject; - forceEnterMode?: boolean; - forcePasteAsPlainText?: boolean; - forceSimpleAmpersand?: boolean; - format_address?: config.styleObject; - format_div?: config.styleObject; - format_h1?: config.styleObject; - format_h2?: config.styleObject; - format_h3?: config.styleObject; - format_h4?: config.styleObject; - format_h5?: config.styleObject; - format_h6?: config.styleObject; - format_p?: config.styleObject; - format_pre?: config.styleObject; - format_tags?: string; - fullPage?: boolean; - - grayt_autoStartup?: boolean; - - height?: string | number; - htmlEncodeOutput?: boolean; - - ignoreEmptyParagraph?: boolean; - image2_alignClasses?: string[]; - image2_altRequired?: boolean; - image2_captionedClass?: string; - image2_disableResizer?: boolean; - image2_prefillDimensions?: boolean; - imageUploadUrl?: string; - image_prefillDimensions?: boolean; - image_previewText?: string; - image_removeLinkByEmptyUrl?: boolean; - indentClasses?: string[]; - indentOffset?: number; - indentUnit?: string; - - jqueryOverrideVal?: boolean; - justifyClasses?: string[]; - - keystrokes?: [number, string][]; - - language?: string; - language_list?: string[]; - linkJavaScriptLinksAllowed?: boolean; - linkShowAdvancedTab?: boolean; - linkShowTargetTab?: boolean; - - magicline_color?: string - magicline_everywhere?: boolean; - magicline_holdDistance?: number; - magicline_keystrokeNext?: number; - magicline_keystrokePrevious?: number; - magicline_tabuList?: string[]; - magicline_triggerOffset?: number; - mathJaxClass?: string; - mathJaxLib?: string; - menu_groups?: string; - menu_subMenuDelay?: number; - - newpage_html?: string; - notification_duration?: number; - - on?: editor.eventObject; - - pasteFilter?: string; - pasteFromWordCleanupFile?: string; - pasteFromWordNumberedHeadingToList?: boolean; - pasteFromWordPromptCleanup?: boolean; - pasteFromWordRemoveFontStyles?: boolean; - pasteFromWorkRemoveStyles?: boolean; - pasteFromWord_heuristicsEdgeList?: boolean; - pasteFromWord_inlineImages?: boolean; - plugins?: string; - protectedSource?: RegExp[]; - - readOnly?: boolean; - removeButtons?: string; - removeDialogTabs?: string; - removeFormatAttributes?: string; - removeFormatTags?: string; - removePlugins?: string; - resize_dir?: string; - resize_enabled?: boolean; - resize_maxHeight?: number; - resize_maxWidth?: number; - resize_minHeight?: number; - resize_minWidth?: number; - - scayt_autoStartup?: boolean; - scayt_contextCommands?: string; - scayt_contextMenuItemsOrder?: string; - scayt_customDictionaryIds?: string; - scayt_customerId?: string; - scayt_disableOptionsStorage?: string | string[]; - scayt_elementsToIgnore?: string; - scayt_handleCheckDirty?: string; - scayt_handleUndoRedo?: string; - scayt_ignoreAllCapsWords?: boolean; - scayt_ignoreDomainNames?: boolean; - scayt_ignoreWordsWithMixedCases?: boolean; - scayt_ignoreWordsWithNumbers?: boolean; - scayt_inlineModeImmediateMarkup?: boolean; - scayt_maxSuggestions?: number; - scayt_minWordLength?: number; - scayt_moreSuggestions?: string; - scayt_multiLanguageMode?: boolean; - scayt_multiLanguageStyles?: { [key: string]: any }; - scayt_sLang?: string; - scayt_serviceHost?: string; - scayt_servicePath?: string; - scayt_servicePort?: string; - scayt_serviceProtocol?: string; - scayt_srcUrl?: string; - scayt_uiTabs?: string; - scayt_userDictionaryName?: string; - - sharedSpaces?: sharedSpace; - shiftEnterMode?: number; - skin?: string; - smiley_columns?: number; - smiley_descriptions?: string[]; - smiley_images?: string[]; - smiley_path?: string; - sourceAreaTabSize?: number; - specialChars?: (string | [string, string])[]; - startupFocus?: string | boolean; - startupMode?: string; - startupOutlineBlocks?: boolean; - startupShowBorders?: boolean; - stylesSet?: string | boolean | config.styleObject[]; - stylesheetParser_skipSelectors?: RegExp; - stylesheetParser_validSelectors?: RegExp; - - tabIndex?: number; - tabSpaces?: number; - templates?: string; - templates_files?: { [key: string]: any }; - templates_replaceContent?: boolean; - title?: string | boolean; - toolbar?: string | (string | string[] | { name: string, items?: string[], groups?: string[] })[] | null; - toolbarCanCollapse?: boolean; - toolbarGroupCycling?: boolean; - toolbarGroups?: (toolbarGroups | string)[]; - toolbarLocation?: string; - toolbarStartupExpanded?: boolean; - - uiColor?: string; - undoStackSize?: number; - uploadUrl?: string; - useComputedState?: boolean; - - width?: string | number; - wsc_cmd?: string; - wsc_customDictionaryIds?: string; - wsc_customLoaderScript?: string; - wsc_customerId?: string; - wsc_height?: string; - wsc_lang?: string; - wsc_left?: string; - wsc_top?: string; - wsc_userDictionaryName?: string; - wsc_width?: string; - } - - interface dataProcessor { - toDataFormat(html: string, fixForBody: string): void; - toHtml(data: string, fixForBody?: string): void; - } - - class dialog { - readonly state: number; - - constructor(editor: editor, dialogName: string); - - addFocusable(element: dom.element, index?: number): void; - addPage(contents: { [key: string]: any }): void; - click(id: string): any; - commitContent(): void; - diableButton(id: string): void; - enableButton(id: string): void; - foreach(fn: () => void): dialog; - getButton(id: string): ui.dialog.button; - getContentElement(pageId: string, elementId: string): ui.dialog.uiElement; - getElement(): dom.element; - getName(): string; - getPageCount(): number; - getParentEditor(): editor; - getPosition(): { [key: string]: any }; - getSelectedElement(): dom.element; - getSize(): { [key: string]: any }; - getValueOf(pageId: string, elementId: string): any; - hide(): void; - hidePage(id: string): void; - layout(): void; - move(x: number, y: number, save: boolean): void; - reset(): dialog; - resize(width: number, height: number): void; - selectPage(id: string): void; - setState(state: number): void; - setValueOf(pageId: string, elementId: string, value: any): void; - setupContent(): void; - show(): void; - showPage(id: string): void; - updateStyle(): void; - - static add(name: string, dialogDefinition: string | ((editor: editor) => dialog.IDialogDefinition)): void; - static addIframe(name: string, title: string, minWidth: number, minHeight: number, onContentLoad?: () => void, userDefinition?: { [key: string]: any }): void; - static addUIElement(typeName: string, builder: () => void): void; - static cancelButton(): void; - static exists(name: string | number): void; // NOTE: documentation says object, but it's an array accessor, so really a string or number will work - static getCurrent(): dialog; - static isTabEnabled(editor: editor, dialogName: string, tabName: string): boolean; - static okButton(): void; - } - - namespace dialog { - - namespace definition { - - interface button extends uiElement { - disabled?: boolean; - } - - interface checkbox extends uiElement { - default?: string; - validate?: () => boolean; - } - - interface content { - accessKey?: string; - elements?: dialog.definition.uiElement[]; - id?: string; - label?: string; - title?: string; - } - - interface file extends labeledElement { - action?: string; - size?: string; - validate?: () => boolean; - } - - interface fileButton extends uiElement { - filebrowser?: string; - for?: string; - validate?: () => boolean; - } - - interface hbox extends uiElement { - children?: ui.dialog.uiElement[]; - height?: number; - padding?: number; - validate?: () => boolean; - widths?: number[]; - } - - interface html extends uiElement { - html?: string; - } - - interface labeledElement extends uiElement { - controlStyle?: string; - inputStyle?: string; - labelLayout?: string; - labelStyle?: string; - widths?: number[]; - } - - interface radio extends labeledElement { - default?: string; - items?: string[] | (string[])[]; - validate?: () => boolean; - } - - interface select extends labeledElement { - default?: string; - items?: string[] | (string[])[]; - multiple?: boolean; - size?: number; - validate?: () => boolean; - } - - interface textarea extends labeledElement { - bidi?: boolean; - cols?: number; - default?: string; - rows?: number; - validate?: () => boolean; - } - - interface textInput extends labeledElement { - bidi?: boolean; - default?: string; - maxLength?: number; - size?: number; - validate?: () => boolean; - } - - interface uiElement { - align?: string; - className?: string; - commit?: (widget: plugins.widget) => void; - id?: string; - label?: string; - onHide?: (elem: ui.dialog.uiElement) => void; - onLoad?: (elem: ui.dialog.uiElement) => void; - onShow?: (elem: ui.dialog.uiElement) => void; - requiredContent?: string | { [key: string]: any } | style; - setup?: (widget: plugins.widget) => void; - style?: string; - title?: string; - type?: string; - } - - interface vbox extends uiElement { - children?: ui.dialog.uiElement[]; - expand?: boolean; - heights?: number[]; - padding?: number; - styles?: string; - width?: number[]; - } - } - - interface IDialogDefinition { - buttons?: dialog.definition.button[]; - contents?: dialog.definition.content[]; - height?: number; - minHeight?: number; - minWidth?: number; - onCancel?: () => void; - onLoad?: () => void; - onOk?: () => void; - onShow?: () => void; - onHide?: () => void; - resizable?: number; - title?: string; - width?: number; - } - } - - class dialogCommand { - value: any; - - constructor(dialogName: string, ext?: { tabId?: string }); - } - - interface dtdDefinition { - [outerTagName: string]: {[innerTagName: string]: 1}; - $block: {[tagName: string]: 1}; - $blockLimit: {[tagName: string]: 1}; - $cdata: {[tagName: string]: 1}; - $editable: {[tagName: string]: 1}; - $empty: {[tagName: string]: 1}; - $inline: {[tagName: string]: 1}; - $intermediate: {[tagName: string]: 1}; - $list: {[tagName: string]: 1}; - $listItem: {[tagName: string]: 1}; - $nonBodyContent: {[tagName: string]: 1}; - $nonEditable: {[tagName: string]: 1}; - $object: {[tagName: string]: 1}; - $removeEmpty: {[tagName: string]: 1}; - $tabIndex: {[tagName: string]: 1}; - $tableContent: {[tagName: string]: 1}; - $transparent: {[tagName: string]: 1}; - } - - var dtd: dtdDefinition; - - class editable extends dom.element { - hasFocus: boolean; - readonly status: string; - - constructor(editor: editor, element: HTMLElement | dom.element); - attachClass(className: string): void; - attachListener(obj: event | editable, eventName: string, listenerFunction: (ei: eventInfo) => void, scopeobj?: {}, listenerData?: any, priority?: number): listenerRegistration; - changeAttr(attr: string, val: string): void; - detach(): void; - insertElement(element: dom.element, range?: dom.range): void; - insertHtml(data: string, mode?: string, range?: dom.range): void; - insertText(text: dom.text): void; - isInline(): boolean; - setReadOnly(isReadOnly: boolean): void; - } - - class editor extends event { - readonly activeEnterMode: number; - readonly activeFilter: filter; - readonly activeShiftEnterMode: number; - readonly blockless: boolean; - readonly config: config; - readonly container: dom.element; - readonly contextMenu: plugins.contextMenu; - copyFormatting: plugins.copyformatting.state; - dataProcessor: dataProcessor; - readonly document: dom.document; - readonly element: dom.element; - readonly elementMode: number; - readonly enterMode: number; - readonly filter: filter; - readonly focusManager: focusManager; - readonly id: string; - readonly keystrokeHandler: keystrokeHandler; - readonly lang: any; - readonly langCode: string; - readonly mode: string; - readonly name: string; - readonly pasteFilter: filter; - readonly plugins: any; - readonly readOnly: boolean; - readonly shiftEnterMode: number; - readonly status: string; - readonly tabIndex: number; - readonly templates: any; - readonly title: any; - readonly toolbar: any; - readonly ui: ui; - readonly widgets: plugins.widget.repository; - readonly window: dom.window; - - constructor(instanceConfig?: config, element?: dom.element, mode?: number); - addCommand(commandName: string, commandDefinition: commandDefinition): void; - addContentsCss(cssPath: string): void; - addFeature(feature: feature): boolean; - addMenuGroup(name: string, order?: number): void; - addMenuItem(name: string, definition?: IMenuItemDefinition): void; - addMenuItems(definitions: { [id:string]: IMenuItemDefinition }): void; - addMode(mode: string, exec: () => void): void; - addRemoveFormatFilter(func: (element: dom.element) => boolean): void; - applyStyle(style: style): void; - attachStyleStateChange(style: style, callback: (state: number) => void): void; - checkDirty(): boolean; - createFakeElement(realElement: dom.element, className: string, realElementType: string, isResizable: boolean): void; - createFakeParserElement(realElement: dom.element, className: string, realElementType: string, isResizable: boolean): void; - createRange(): dom.range; - destroy(noUpdate?: boolean): void; - editable(elementOrEditable?: dom.element | editable): editable; - elementPath(startNode?: dom.node): dom.elementPath; - execCommand(commandName: string, data?: any): boolean; - extractSelectedHtml(toString?: boolean, removeEmptyBlock?: boolean): dom.documentFragment | string | void; - focus(): void; - forceNextSelectionCheck(): void; - getClipboardData(callbackOrOptions: { title: string } | ((data: any) => void), callback: (data: any) => void): void; - getColorFromDialog(callback: (color: string) => void, scope?: { [key: string]: any }): void; - getCommand(commandName: string): command; - getCommandKeystroke(command: command | string): number | null; - getData(internal: boolean): string; - getMenuItem(name: string): IMenuItemDefinition; - getResizable(forContents: boolean): dom.element; - getSelectedHtml(toString?: false): dom.documentFragment; - getSelectedHtml(toString: true): string; - getSelectedHtml(toString?: boolean): dom.documentFragment | string; - getSelection(forceRealSelection: boolean): dom.selection; - getSnapshot(): string; - getStylesSet(callback: (stylesDefinitions: style.definition[]) => void): void; - getUiColor(): string; - insertElement(element: dom.element): void; - insertHtml(html: string, mode?: string, range?: dom.range): void; - insertText(text: string): void; - loadSnapshot(snapshot: any): void; - lockSelection(sel?: dom.selection): boolean; - openDialog(dialogName: string, callback: () => void): dialog; - popup(url: string, width?: number | string, height?: number | string, options?: string): void; - removeMenuItem(name: string): void; - removeStyle(style: style): void; - resetDirty(): void; - resetUndo(): void; - resize(width: number | string, height: number | string, isContentHeight?: boolean, resizeInner?: boolean): void; - restoreRealElement(fakeElement: dom.element): dom.element; - selectionChange(checkNow?: boolean): void; - setActiveEnterMode(enterMode: number, shiftEnterMode: number): void; - setActiveFilter(filter: filter): void; - setData(data: string, options?: { internal?: boolean; callback?: () => void; noSnapshot?: boolean; }): void; - setKeystroke(keystroke: number, behavior: string | boolean): void; - setKeystroke(keystroke: [number, string | boolean][]): void; - setMode(newMode: string, callback: () => void): void; - setReadOnly(isReadOnly?: boolean): void; - setUiColor(color: string): void; - showNotification(message: string, type: plugins.notification.type, progressOrDuration: number): plugins.notification; - unlockSelection(restore?: boolean): void; - updateElement(): void; - } - - namespace editor { - interface eventObject { - activeEnterModeChange?: (evt: eventInfo) => void; - activeFilterChange?: (evt: eventInfo) => void; - afterCommandExec?: (evt: eventInfo) => void; - afterInsertHtml?: (evt: eventInfo) => void; - afterPaste?: (evt: eventInfo) => void; - afterPasteFromWord?: (evt: eventInfo) => void; - afterSetData?: (evt: eventInfo) => void; - afterUndoImage?: (evt: eventInfo) => void; - ariaEditorHelpLabel?: (evt: eventInfo) => void; - ariaWidget?: (evt: eventInfo) => void; - autogrow?: (evt: eventInfo) => void; - - beforeCommandExec?: (evt: eventInfo) => void; - beforeDestroy?: (evt: eventInfo) => void; - beforeGetData?: (evt: eventInfo) => void; - beforeModeUnload?: (evt: eventInfo) => void; - beforeSetMode?: (evt: eventInfo) => void; - beforeUndoImage?: (evt: eventInfo) => void; - blur?: (evt: eventInfo) => void; - - change?: (evt: eventInfo) => void; - configLoaded?: (evt: eventInfo) => void; - contentDirChanged?: (evt: eventInfo) => void; - contentDom?: (evt: eventInfo) => void; - contentDomInvalidated?: (evt: eventInfo) => void; - contentDomUnload?: (evt: eventInfo) => void; - customConfigLoaded?: (evt: eventInfo) => void; - - dataFiltered?: (evt: eventInfo) => void; - dataReady?: (evt: eventInfo) => void; - destroy?: (evt: eventInfo) => void; - dialogHide?: (evt: eventInfo) => void; - dialogShow?: (evt: eventInfo) => void; - dirChanged?: (evt: eventInfo) => void; - doubleclick?: (evt: eventInfo) => void; - dragend?: (evt: eventInfo) => void; - dragstart?: (evt: eventInfo) => void; - drop?: (evt: eventInfo) => void; - - elementsPathUpdate?: (evt: eventInfo) => void; - - fileUploadRequest?: (evt: eventInfo) => void; - fileUploadResponse?: (evt: eventInfo) => void; - floatingSpaceLayout?: (evt: eventInfo) => void; - focus?: (evt: eventInfo) => void; - - getData?: (evt: eventInfo) => void; - getSnapshot?: (evt: eventInfo) => void; - - insertElement?: (evt: eventInfo) => void; - insertHtml?: (evt: eventInfo) => void; - insertText?: (evt: eventInfo) => void; - instanceReady?: (evt: eventInfo) => void; - - key?: (evt: eventInfo) => void; - - langLoaded?: (evt: eventInfo) => void; - loadSnapshot?: (evt: eventInfo) => void; - loaded?: (evt: eventInfo) => void; - lockSnapshot?: (evt: eventInfo) => void; - maximize?: (evt: eventInfo) => void; - menuShow?: (evt: eventInfo) => void; - mode?: (evt: eventInfo) => void; - - notificationHide?: (evt: eventInfo) => void; - notificationShow?: (evt: eventInfo) => void; - notificationUpdate?: (evt: eventInfo) => void; - - paste?: (evt: eventInfo) => void; - pasteFromWord?: (evt: eventInfo) => void; - pluginsLoaded?: (evt: eventInfo) => void; - - readOnly?: (evt: eventInfo) => void; - removeFormatCleanup?: (evt: eventInfo) => void; - required?: (evt: eventInfo) => void; - resize?: (evt: eventInfo) => void; - - save?: (evt: eventInfo) => void; - saveSnapshot?: (evt: eventInfo) => void; - selectionChange?: (evt: eventInfo) => void; - setData?: (evt: eventInfo) => void; - stylesSet?: (evt: eventInfo) => void; - - template?: (evt: eventInfo) => void; - toDataFormat?: (evt: eventInfo) => void; - toHtml?: (evt: eventInfo) => void; - - unlockSnapshot?: (evt: eventInfo) => void; - updateSnapshot?: (evt: eventInfo) => void; - - widgetDefinition?: (evt: eventInfo) => void; - } - } - - namespace env { - var air: boolean; - var chrome: boolean; - var cssClass: string; - var edge: boolean; - var gecko: boolean; - var hc: boolean; - var hidpi: boolean; - var iOS: boolean; - var ie: boolean; - var isCompatible: boolean; - var mac: boolean; - var needsBrFiller: boolean; - var needsNbspFiller: boolean; - var quirks: boolean; - var safari: boolean; - var version: number; - var webkit: boolean; - - function secure(): boolean; - } - - class event { - static useCapture: boolean; - - constructor(); - capture(): void; - define(name: string, meta: { [key: string]: any }): void; - fire(eventName: string, data?: { [key: string]: any }, editor?: editor): any; - fireOnce(eventName: string, data?: { [key: string]: any }, editor?: editor): any; - hasListeners(eventName: string): boolean; - on(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: { [key: string]: any } | null, listenerData?: any, priority?: number): listenerRegistration; - once(eventName: string, listenerFunction: (eventInfo: eventInfo) => void, scopeObj?: { [key: string]: any } | null, listenerData?: any, priority?: number): listenerRegistration; - removeAllListeners(): void; - removeListener(eventName: string, listenerFunction: (eventInfo: eventInfo) => void): void; - - static implementOn(targetObject: { [key: string]: any }): void; - } - - interface eventInfo { - data: any; - editor: editor; - listenerData: any; - name: string; - sender: { [key: string]: any }; - - cancel(): void; - removeListener(): void; - stop(): void; - } - - interface feature { - allowedContent?: filter.allowedContentRules; - contentForms?: any; - contentTransformations?: any; - name?: string; - requiredContent?: string | style; - toFeature?: () => feature; - } - - namespace fileTools { - var isFileUploadSupported: boolean; - - function addUploadWidget(editor: editor, name: string, def: uploadWidgetDefinition): void; - function bindNotification(editor: editor, fileLoader: fileLoader): void; - function getUploadUrl(config: { [key: string]: any }, type?: string): string; - function isTypeSupported(file: Blob, supportedTypes: RegExp): boolean; - function markElement(element: dom.element, widgetName: string, loaderId: number): void; - - class fileLoader extends event { - readonly data: string; - readonly file: Blob; - readonly fileName: string; - readonly id: number; - readonly loaded: number; - readonly message: string; - readonly reader: FileReader; - readonly responseData: any; - status: string; - readonly total: number; - readonly uploadTotal: number; - readonly uploadUrl: string; - readonly uploaded: string; - readonly url: string; - readonly xhr: XMLHttpRequest; - - constructor(editor: editor, fileOrData: Blob | string, fileName?: string); - abort(): void; - isFinished(): boolean; - load(): void; - loadAndUpload(url: string, additionalRequestParameters?: any): void; - update(): void; - upload(url: string, additionalRequestParameters?: any): void; - } - - class uploadRepository extends event { - readonly loaders: fileLoader[]; - - constructor(editor: editor); - create(fileOrData: Blob | string, fileName: string, loaderType?: any): fileLoader; - isFinished(): boolean; - } - - interface uploadWidgetDefinition extends plugins.widget.definition { - additionalRequestParameters: any; - fileToElement: (pastedFile: any) => HTMLElement; - loadMethod: string; - loaderType: any; - onAbort: () => boolean; - onError: () => boolean; - onLoaded: () => boolean; - onUploaded: () => boolean; - onUploading: () => boolean; - replaceWith: () => any; - skipNotifications: boolean; - supportedTypes: string; - uploadUrl: string; - } - } - - module filter { - type allowedContentRule = string | style | { [key: string]: any}; - type allowedContentRules = allowedContentRule | allowedContentRule[]; - type contentRule = string | style; - type disallowedContentRules = string | { [key: string]: any}; - - interface transformation { - check?: string; - element?: string | style; - left?: (element: htmlParser.element | style) => boolean; - right: (element: htmlParser.element, tools: string | filter.transformationTools) => boolean; - } - - var transformationTools: transformationTools; - - interface transformationTools { - alignmentToAttribute(element: htmlParser.element): void; - alignmentToStyle(element: htmlParser.element): void; - lengthToAttribute(element: htmlParser.element, styleName: string, attrName?: string): void; - lengthToStyle(element: htmlParser.element, styleName: string, attrName?: string): void; - matchesTyle(element: htmlParser.element, style: style): void; - sizeToAttribute(element: htmlParser.element): void; - sizeToStyle(element: htmlParser.element): void; - splitBorderShorthand(element: htmlParser.element): void; - splitMarginShorthand(element: htmlParser.element): void; - transform(element: htmlParser.element, form: style | string): void; - } - } - - class filter { - readonly allowedContent: filter.allowedContentRules[]; - readonly customConfig: boolean; - readonly disabled: boolean; - readonly disallowedContent: any[]; - readonly editor: editor; - readonly elementCallbacks:((element: htmlParser.element) => number)[]; - readonly id: number; - - static instances: { [id: string]: filter }; - - constructor(editorOrRules: editor | filter.allowedContentRules); - addContentForms(forms: any[]): void; - addElementCallback(callback: (element: htmlParser.element) => number): void; - addFeature(feature: feature): boolean; - addTransformations(transformations: (string | filter.transformation)[][]): void; - allow(newRules: filter.allowedContentRules, featureName?: string, overrideCustom?: boolean): boolean; - applyTo(fragment: htmlParser.fragment | htmlParser.element, toHrml: boolean, transformOnly: boolean, enterMode: number): boolean; - check(test: filter.contentRule, applyTransformations?: boolean, strictCheck?: boolean): boolean; - checkFeature(feature: feature): boolean; - clone(): filter; - destroy(): void; - disable(): void; - disallow(newRules: filter.disallowedContentRules): void; - getAllowedEnterMode(defaultMode: number, reverse?: boolean): number; - } - - class focusManager { - currentActive: dom.domObject; - hasFocus: boolean; - - constructor(editor: editor); - add(element: dom.element, isCapture: boolean): void; - blur(noDelay?: boolean): void; - focus(currentActive?: dom.element): void; - lock(): void; - remove(element: dom.element): void; - unlock(): void; - } - - class htmlDataProcessor implements dataProcessor { - dataFilter: htmlParser.filter; - htmlFilter: htmlParser.filter; - writer: htmlParser.basicWriter; - - constructor(editor: editor); - toDataFormat(html: string, options?: string | { context?: string, filter?: filter, enterMode?: number }): string; - toHtml(data: string, options?: string | htmlDataProcessorOptions): string; - } - - interface htmlDataProcessorOptions { - context?: string; - fixForBody?: boolean; - filter?: filter; - dontFilter?: boolean; - enterMode?: number; - protectedWhitespaces?: boolean; - } - - namespace htmlParser { - class basicWriter { - constructor(); - attribute(attName: string, attValue: string): void; - closeTag(tagName: string): void; - comment(comment: string): void; - getHtml(reset: boolean): string; - openTag(tagName: string, attributes: { [key: string]: string }): void; - openTagClose(tagName: string, isSelfClose: boolean): void; - reset(): void; - text(text: string): void; - write(data: string): void; - } - - class cdata extends node { - constructor(value: string); - type: number; - writeHtml(writer: htmlParser.basicWriter): void; - } - - class comment extends node { - type: number; - value: string; - - constructor(value: string); - filter(filter: filter): boolean; - writeHtml(writer: htmlParser.basicWriter, filter?: htmlParser.filter): void; - } - - class cssStyle { - constructor(elementOrStyleText: htmlParser.element | string); - populate(obj: htmlParser.element | dom.element | { [key: string]: any}): void; - } - - class element extends node { - attributes: { [name: string]: string }; - children: htmlParser.node[]; - name: string; - type: number; - - constructor(name: string, attributes: { [name: string]: string }); - add(node: node, index?: number): void; - addClass(className: string): void; - clone(): element; - filter(filter: htmlParser.filter): boolean; - filterChildren(filter: htmlParser.filter): void; - find(criteria: string | ((el: htmlParser.node) => boolean), recursive?: boolean): htmlParser.node[]; - forEach(callback: (node: htmlParser.node) => void | boolean, type?: number, skipRoot?: boolean): void; - getFirst(condition: string | { [key: string]: string } | ((node: htmlParser.node) => boolean)): htmlParser.node; - getHtml(): string; - getOuterHtml(): string; - hasClass(className: string): boolean; - removeClass(className: string): void; - replaceWithChildren(): void; - setHtml(html: string): void; - split(index: number): htmlParser.element; - writeChildrenHtml(writer: htmlParser.basicWriter, filter?: htmlParser.filter): void; - writeHtml(writer: basicWriter, filter?: htmlParser.filter): void; - } - - class filter { - attributeNameRules: filterRulesGroup; - attributesRules: { [name: string]: filterRulesGroup }; - commentRules: filterRulesGroup; - elementNameRules: filterRulesGroup; - elementsRules: { [name: string]: filterRulesGroup }; - id: number; - rootRules: filterRulesGroup; - textRules: filterRulesGroup; - - constructor(rules?: filterRulesDefinition); - addRules(rules: filterRulesDefinition, options?: number | { priority?: number; applyToAll?: boolean; }): void; - applyTo(node: node): void; - } - - interface filterRulesDefinition { - elementNames: any; - attributeNames: any; - elements: any; - attributes: any; - text: any; - comment: any; - root: any; - } - - class filterRulesGroup { - rules: { value: rule, priority: number, option: ruleOptions }[]; - - add(rule: rule, priority: number, options: ruleOptions): void; - addMany(rules: { [key: string]: any }[], priority: number, options: ruleOptions): void; - exec(currentValue: htmlParser.node | htmlParser.fragment | string): htmlParser.node | htmlParser.fragment | string; - execOnName(currentName: string): string; - findIndex(priority: number): number; - } - - class fragment { - children: htmlParser.node[]; - parent: htmlParser.fragment; - readonly type: number; - - constructor(); - - add(node: htmlParser.node, index?: number): void; - filter(filter: htmlParser.filter): void; - filterChildren(filter: htmlParser.filter, filterRoot?: boolean): void; - forEach(callback: (node: htmlParser.node,) => void | boolean, type?: number, skipRoot?: boolean): void; - writeChildrenHtml(writer: basicWriter, filter?: htmlParser.filter, filterRoot?: boolean): void; - writeHtml(writer: basicWriter, filter?: htmlParser.filter): void; - - static fromBBCode(source: string): htmlParser.fragment; - static fromHtml(fragmentHtml: string, parent?: htmlParser.element | string, fixingBlock?: string | boolean): fragment | htmlParser.element; - } - - class node { - constructor(); - getAscendant(condition: string | { [name: string]: string | ((node: htmlParser.element) => boolean)}): element; - getIndex(): number; - insertAfter(node: node): void; - insertBefore(node: node): void; - remove(): node; - replaceWith(node: node): void; - wrapWith(wrapper: element): element; - } - - type rule = ((value: htmlParser.node | htmlParser.fragment | string) => boolean) | [ string, string ]; - - interface ruleOptions { - applyToAll?: boolean, - excludeNestedEditable?: boolean - } - - class text extends node { - constructor(value: string); - type: number; - filter(filter: filter): boolean; - writeHtml(writer: basicWriter, filter?: filter): void; - } - } - - class htmlWriter extends htmlParser.basicWriter { - indentationChars: string; - lineBreakChars: string; - selfClosingEnd: string; - - indentation(): void; - lineBreak(): void; - setRules(tagName: string, rules: { [key: string]: any }): void; - } - - class keystrokeHandler { - blockedKeystrokes: { [key: number]: string | boolean }; - keystrokes: { [key: number]: string | boolean }; - - constructor(editor: editor); - - attach(domObject: dom.domObject): void; - } - - namespace lang { - var languages: { [code: string]: number }; - var rtl: { [code: string]: number }; - - function detect(defaultLanguage: string, probeLanguage?: string): string; - function load(languageCode: string, defaultLanguage: string, callback: (code: string, entries: any) => void): void; - } - - namespace loader { - var loadedScripts: string[]; - var scripts: string[]; - - function load(scriptName: string, defer?: boolean): void; - function loadPending(): void; - } - - class menu { - constructor(); - - add(item: any): void; - addListener(listenerFn: (startElement: dom.element, selection: dom.selection, path: dom.elementPath) => any): void; - findItemByCommandName(commandName: string): { item: any, element: dom.element }; - hide(returnFocus?: boolean): void; - removeAll(): void; - show(offsetParent: dom.element, corner?: number, offsetX?: number, offsetY?: number): void; - } - - interface pluginDefinition { - hidpi?: boolean; - lang?: string | string[]; - requires?: string | string[]; - - afterInit?(editor: editor): any; - beforeInit?(editor: editor): any; - init?(editor: editor): void; - onLoad?(): any; - } - - namespace plugins { - - namespace cloudservices { - class cloudServicesLoader extends fileTools.fileLoader { - customToken: string; - - constructor(editor: editor, fileOrData: Blob | string, fileName?: string, token?: string); - loadAndUpload(url?: string, additionalRequestParameters?: any): void; - upload(url?: string, additionalRequestParameters?: any): void; - } - } - - class autoEmbed { - getWidgetDefinition(editor: editor, url: string): widget.definition; - } - - namespace balloontoolbar { - const PRIORITY: { [pri: string]: number }; - - class context { - editor: editor; - options: contextDefinition; - toolbar: ui.balloonToolbar; - - constructor(editor: editor, options: contextDefinition); - destroy(): void; - hide(): void; - refresh(): void; - show(pointedElement?: dom.element): void; - } - - interface contextDefinition { - cssSelector?: string; - priority?: number; - widgets?: string[] | string; - - refresh?: (editor: editor, path: dom.elementPath, selection: dom.selection) => dom.element; - } - - class contextManager { - editor: editor; - - constructor(editor: editor); - add(context: context): void; - check(selection?: dom.selection): void; - create(options: contextDefinition): context; - destroy(): void; - hide(): void; - } - } - - namespace clipboard { - const isCustomCopyCutSupported: boolean; - const isCustomDataTypesSupported: boolean; - const isFileApiSupported: boolean; - const mainPasteEvent: string; - - function addPasteButton(editor: editor, name: string, definition: { [key: string]: any}): void; - function canClipboardApiBeTrusted(dataTransfer: dataTransfer, editor: editor): boolean; - function getDropTarget(editor: editor): dom.domObject; - function getRangeAtDropPosition(domEvent: Event, editor: editor): dom.range; - function initDragDataTransfer(evt?: dom.event, editor?: editor): void; - function initPasteDataTransfer(evt?: dom.event, sourceEditor?: editor): void; - function preventDefaultDropOnElement(element: dom.element): void; - function resetDragDataTransfer(): void; - - class dataTransfer { - readonly $: DataTransfer; - readonly id: string; - readonly sourceEditor: editor; - - constructor(nativeDataTransfer?: DataTransfer, editor?: editor); - cacheData(): void; - getData(type: string, getNative?: boolean): string; - getFile(i: number): File; - getFilesCount(): number; - getTransferType(targetEditor: editor): number; - isEmpty(): boolean; - setData(type: string, value: string): void; - storeId(): void; - } - - class fallbackDataTransfer { - constructor(dataTransfer: dataTransfer); - getData(type: string, getNative?: boolean): string; - isRequired(): boolean; - setData(type: string, value: string): string; - } - } - - namespace condesnippet { - function setHighlighter(highlighter: highlighter): void; - - class highlighter { - highlighter: (code: string, lang: string, callback: (highlightedCode: string) => void) => void; - init: (ready: () => void) => void; - languages: { [lang: string]: string }; - readonly queue: ((code: string, lang: string, callback: (highlightedCode: string) => void) => void)[]; - readonly ready: boolean; - - highlight(code: string, lang: string, callback: (highlightedCode: string) => void): void; - } - } - - class contextMenu extends menu { - constructor(editor: editor); - addTarget(element: dom.element, nativeContextMenuOnCtrl?: boolean): void; - open(offsetParent: dom.element, corner?: number, offsetX?: number, offsetY?: number): void; - } - - namespace copyformatting { - var breakOnElements: string[]; - var elementsForInlineTransform: string[]; - var excludedAttributes: string[]; - var excludedAttributesFromInlineTransform: string[]; - var inlineBoundary: string[]; - var preservedElements: string[]; - - class state extends event { - editor: editor; - filter: filter; - sticky: boolean; - styles: style[]; - - constructor(editor: editor); - } - } - - namespace easyimage { - - } - - namespace embedBase { - function createWidgetBaseDefinition(editor: editor): baseDefinition; - - interface baseDefinition extends widget.definition { - providerUrl: template; - urlRegExp: RegExp; - - getErrorMessage(messageTypeOrMessage: string, url?: string, suffix?: string): string; - isUrlValid(url: string): boolean; - loadContent(url: string, callback?: () => void, errorCallback?: (error: string) => void, noNotifications?: boolean): request; - } - - interface request { - callback: () => void; - errorCallback: (error: string) => void; - response: { [key: string]: string }; - task: notificationAggregator.task; - url: string; - - cancel(): void; - } - } - - namespace image2 { - function checkHasNaturalRatio(image: dom.element): boolean; - function getLinkAttributesGetter(): (editor: editor, data: { [key: string]: string }) => { set: { [tag: string]: string }, removed: string[] }; - function getLinkAttributesParser(): (editor: editor, element: dom.element) => { [key: string]: string }; - function getNatural(image: dom.element): { [key: string]: string }; - } - - namespace imagebase { - var featuresDefinitions: { [key: string]: string }; - - function addFeature(editor: editor, name: string, definition: imageWidgetDefinition): imageWidgetDefinition; - function addImageWidget(editor: editor, name: string, definition: imageWidgetDefinition): void; - - interface imageWidgetDefinition extends widget.definition { - features: string[]; - upcast: string; - } - - class progressBar extends progressReporter { - bar: dom.element; - - constructor(); - - } - - class progressReporter { - wrapper: dom.element; - - constructor(wrapperHtml?: string); - aborted(): void; - bindLoader(loader: fileTools.fileLoader): void; - done(): void; - failed(): void; - remove(): void; - updated(progress: number): void; - } - } - - namespace indent { - function registerCommands(editor: editor, commands: { [key: string]: command} ): void; - - class genericDefinition implements commandDefinition { - async: boolean; - canUndo: boolean; - context: boolean; - contextSensitive: boolean; - editorFocus: boolean; - fakeKeystroke: number; - readonly isIndent: boolean; - modes: { [key: string]: any }; - readOnly: boolean; - startDisabled: boolean; - - exec(editor: editor, data?: any): boolean; - refresh?(editor: editor, path: dom.elementPath): void; - } - - class specificDefinition { - database: { [key: string]: any }; - readonly enterBr: boolean; - readonly indentKey: { [key: string]: any }; - readonly isIndent: boolean; - readonly jobs: { [priority: string]: { refresh: (editor: editor, path: dom.elementPath) => number, exec: (editor: editor) => boolean } }; - readonly relatedGlobal: { [key: string]: any }; - - execJob(editor: editor, priority: number): boolean; - getContext(node: dom.elementPath): dom.element; - refreshJob(editor: editor, priority: number): number; - } - } - - namespace indentList { - function firstItemInPath(query: string | string[] | { [tagName: string]: any} | dom.element | ((element: dom.element) => boolean)): boolean; - } - - namespace link { - // DEPRECATED 4.3.3 - const emptyAnchorFix: boolean; - - // DEPRECATED 4.3.3 - const fakeAnchor: boolean; - - // DEPRECATED 4.3.3 - const synAnchorSelector: boolean; - - function getEditorAnchors(editor: editor): dom.element[]; - function getLinkAttributes(editor: editor, data: { [key: string]: any}): { set: { [key: string]: string }, removed: string[] } - function getSelectedLink(editor: editor, returnMultiple?: boolean): dom.element | dom.element[]; - function parseLinkAttributes(editor: editor, element: dom.element): { [key: string]: any }; - function showDisplayTextForElement(element: dom.element, editor: editor): boolean; - function tryRestoreFakeAnchor(editor: editor, element: dom.element): dom.element; - } - - class list { - arrayToList(listArray: any, database: any, paragraphMode: any, dir: any): void; - listToArray(listNode: any, database: any, baseArray: any, baseIndentLevel: any, grandparentNode: any): void; - } - - class notification { - readonly area: notification.area; - readonly duration: number; - readonly editor: editor; - readonly element: dom.element; - readonly id: number; - readonly message: string; - readonly progress: number; - readonly type: notification.type; - - constructor(editor: editor, options: notification.options); - hide(): void; - isVisible(): boolean; - show(): void; - update(options: notification.updateOptions): void; - } - - namespace notification { - interface area { - readonly editor: editor; - readonly element: dom.element; - readonly notifications: notification[]; - - add(notification: notification): void; - remove(notification: notification): void; - } - - interface optionsBase { - duration?: number; - progress?: number; - type?: type; - } - - interface options extends optionsBase { - message: string; - } - - interface updateOptions extends optionsBase { - message?: string; - important?: boolean; - } - - type type = 'info' | 'warning' | 'success' | 'progress'; - } - - class notificationAggregator extends event { - readonly editor: editor; - readonly notification: notification; - - constructor(editor: editor, message: string, singularMessage?: string); - createTask(options?: { weight?: number }): notificationAggregator.task; - getDoneTaskCount(): number; - getPercentage(): number; - getTaskCount(): number; - isFinished(): boolean; - update(): void; - } - - namespace notificationAggregator { - class task extends event { - constructor(weight?: number); - cancel(): void; - done(): void; - isCanceled(): boolean; - isDone(): boolean; - update(weight: number): void; - } - } - - namespace pastefromword { - class lists { - numbering: lists.numbering; - } - - namespace lists { - class numbering { - getStyle(marker: string): string; - toNumber(marker: string, markerType: string): number; - } - } - - class styles { - pushStylesLower(element: htmlParser.element, exceptions: { [style: string]: boolean }, wrapText?: boolean ): boolean; - } - } - - namespace tableselection { - function getCellsBetween(first: dom.element, last: dom.element): dom.element[]; - } - - namespace widget { - var WRAPPER_CLASS_PREFIX: string; - - function getNestedEditable(guard: dom.element, node: dom.node): dom.element; - function isDomDragHandler(node: dom.node): boolean; - function isDomDragHandlerContainer(node: dom.node): boolean; - function isDomNestedEditable(node: dom.node): boolean; - function isDomWidget(node: dom.node): boolean; - function isDomWidgetElement(node: dom.node): boolean; - function isDomWidgetWrapper(node: dom.node): boolean; - function isParserWidgetElement(node: dom.node): boolean; - function isParserWidgetWrapper(node: dom.node): boolean; - - namespace nestedEditable { - interface definition { - allowedContent?: filter.allowedContentRules; - disallowedContent?: filter.disallowedContentRules; - pathName?: string; - selector?: string; - } - } - - class nestedEditable extends dom.element { - readonly editor: editor; - readonly enterMode: number; - readonly filter: filter; - readonly shiftEnterMode: number; - - constructor(editor: editor, element: dom.element, config: { filter?: filter }); - getData(): string; - setData(data: string): void; - } - - - interface definition extends feature { - button?: string; - data?: (evt: eventInfo) => void; - defaults?: { [key: string]: any }; - dialog?: string; - downcast?: string | ((element: htmlParser.element) => void); - downcasts?: { [key: string]: any }; - draggable?: boolean; - edit?: () => void; - editables?: { [key: string]: any }; - getLabel?: () => any; - init?: () => void; - inline?: boolean; - insert?: () => void; - mask?: boolean; - parts?: { [key: string]: any }; - pathName?: string; - styleToAllowedContentRules?: (style: style) => filter.allowedContentRules; - styleableElements?: string; - template?: string | template; - upcast?: string | ((element: htmlParser.element, data: any) => boolean); - upcastPriority?: number; - upcasts?: { [key: string]: any }; - } - - class repository extends event { - readonly editor: editor; - readonly focused: widget; - readonly instances: { [id: string]: widget }; - readonly registered: { [name: string]: definition }; - readonly selected: widget[]; - readonly widgetHoldingFocusedEditable: widget; - - add(name: string, widgetDef: plugins.widget.definition): void; - addUpcastCallback(callback: (element: htmlParser.element, data: any) => boolean): void; - checkSelection(): void; - checkWidgets(options?: { initOnlyNew?: boolean; focusInited?: boolean }): void; - del(widget: plugins.widget): void; - destroy(widget: plugins.widget, offline?: boolean): void; - destroyAll(offline?: boolean): void; - finalizeCreation(container: any): void; - getByElement(element: any, checkWrapperOnly: boolean): plugins.widget; - initOn(element: dom.element, widgetDef?: plugins.widget.definition, startupData?: { [key: string]: any }): plugins.widget; - initOn(element: dom.element, widgetDef?: string, startupData?: { [key: string]: any }): plugins.widget; - initOnAll(container?: dom.element): plugins.widget[]; - parseElementClasses(classes: string): any; - wrapElement(element: any, widgetName?: string): any; - } - - class widgetselection { - addFillers(editable: editable): boolean; - removeFillers(editable: editable): void; - } - } - - class widget extends event implements widget.definition { - readonly dataReady: boolean; - readonly definition: plugins.widget.definition; - readonly editor: editor; - readonly element: dom.element; - readonly focusedEditable: plugins.widget.nestedEditable - readonly id: number; - readonly inited: boolean; - readonly ready: boolean; - readonly repository: plugins.widget.repository; - readonly wrapper: dom.element; - - constructor(widgetsRepo: plugins.widget.repository, id: number, element: dom.element, widgetDef: plugins.widget.definition, starupData?: any); - - addClass(className: string): void; - applyStyle(style: style): void; - checkStyleActive(style: style): boolean; - destroy(offline?: boolean): void; - destroyEditable(editableName: string, offline?: boolean): void; - edit(): boolean; - focus(): void; - getClasses(): any; - hasClass(className: string, Whether: boolean): void; - initEditable(editableName: string, definition: plugins.widget.nestedEditable.definition): boolean; - isInited(): boolean; - isReady(): boolean; - removeClass(className: string): void; - removeStyle(style: style): void; - setData(keyOrData: any, value: any): plugins.widget; - setFocused(selected: boolean): plugins.widget; - setSelected(selected: boolean): plugins.widget; - updateDragHandlerPosition(): void; - } - - function add(name: string, definition: pluginDefinition): void; - function add(name: string): void; - function addExternal(name: string, path: string, fileName?: string): void; - function get(name: string): any; - function getFilePath(name: string): string; - function getPath(name: string): string; - function load(name: string, callback: (plugins: string[]) => void, scope?: { [key: string]: any }): void; - function setLang(pluginName: string, languageCode: string, languageEntries: any): void; - var registered: {[key: string]: pluginDefinition}; - } - - class resourceManager { - basePath: string; - externals: { [key: string]: any }; - fileName: string; - loaded: { [key: string]: any }; - registered: { [key: string]: any }; - - constructor(basePath: string, fileName: string); - add(name: string, definition?: pluginDefinition): void; - addExternal(names: string, path: string, fileName?: string): void; - get(name: string): pluginDefinition; - getFilePath(name: string): string; - getPath(name: string): string; - load(name: string | string[], callback: (loaded: string[]) => void, scope?: { [key: string]: any }): void; - } - - // see https://docs.com/ckeditor4/latest/api/CKEDITOR_scriptLoader.html - namespace scriptLoader { - function load(scriptUrls: string | string[], callback: (succeededUrls: boolean | string[], failedUrls?: string[]) => void, scope?: any, showBusy?: boolean): void; - function queue(scriptUrl: string, callback?: (succeeded: boolean) => void): void; - } - - namespace skin { - var icons: { [name: string]: { path: string } }; - var name: string; - var ua: { [name: string]: any }; - - function addIcon(name: string, path: string, offset?: number, bgsize?: string): void; - function chameleon(editor: string, part: string): void; - function getIconStyle(name: string, rtl?: boolean, overridePath?: number, overrideBgsize?: string): any; - function getPath(part: string): any; - function loadPart(part: string, fn: () => void): void; - function path(): string; - } - - namespace style { - function addCustomHandler(defintion: customHandler): style; - function getStyleText(style: definition): string; - - namespace customHandlers { - class widget extends style { - group: any[]; - widget: string; - checkElement(element: dom.element): boolean; - getClassesArray(): string[]; - getDefintion(): definition; - removeStylesFromSameGroup(editor: editor): boolean; - } - } - - interface definition { - attributes?: { [att: string]: string }, - element: string, - name?: string, - styles?: { [att: string]: string }, - type?: string | number - } - - interface customHandler { - type: string | number; - setup?: (style: definition) => void; - assignedTo?: number; - } - } - - class style { - alwaysRemoveElement: boolean; - includeReadonly: boolean; - constructor(styleDefinition: style.definition, variableValues: any); - apply(editor: editor): void; - applyToObject(element: dom.element, editor: editor): void; - applyToRange(range: Range, editor: editor): void; - buildPreview(label?: string): string; - checkActive(elementPath: dom.elementPath, editor: editor): boolean; - checkApplicable(elementPath: dom.elementPath, editor: editor, filter?: filter): boolean; - checkElementMatch(element: dom.element, fullMatch: boolean, editor: editor): boolean; - checkElementRemovable(element: dom.element, fullMatch: boolean, editor: editor): boolean; - getDefintion(): style.definition; - remove(editor: editor): void; - removeFromRange(range: Range, editor: editor): void; - toAllowedContentRules(editor?: editor): filter.allowedContentRules; - } - - class styleCommand { - constructor(style: style, ext?: any); - exec(editor: editor): void; - } - - var stylesSet: resourceManager; - - class template { - readonly source: string; - - constructor(source: string); - output(data: any, buffer?: any[]): string | number; - } - - namespace tools { - function addFunction(fn: () => any, scope?: any): number; - function arrayCompare(arrayA: any[], arrayB: any[]): boolean; - function clone(source: { [key: string]: any }): { [key: string]: any }; - function copy(source: { [key: string]: any }): { [key: string]: any }; - function createClass(definition: { [key: string]: any }): any; - function cssStyleToDomStyle(cssName: string): string; - function cssVendorPrefix(property: string, value: string, asString?: boolean): { [cssClass: string]: string | number }; - function defer(fn: T): T; - function enableHtml5Elements(doc: Document | DocumentFragment, withAppend?: boolean): void; - function escapeCss(selector: string): string; - function eventsBuffer(minInterval: number, output: () => void, scopeObj: any): { input: () => void, reset: () => void }; - function extend(target: { [key: string]: any }, source: { [key: string]: any }, overwrite: boolean, properties: { [key: string]: any }): { [key: string]: any }; - function fixDomain(): boolean; - function genKey(subKey: string): string; - function getCookie(name: string): string; - function getCsrfToken(): string; - function getIndex(array: T[], compareFunction: (element: T) => boolean): number; - function getMouseButton(evt: dom.event): boolean; - function getNextId(): string; - function getNextNumber(): number; - function getUniqueId(): string; - function htmlDecode(text: string): string; - function htmlDecodeAttr(text: string): string; - function htmlEncode(text: string): string; - function htmlEncodeAttr(text: string): string; - function indexOf(array: T[], value: T | ((el: T) => boolean)): number; - function isArray(object: any): object is T[]; - function isEmpty(object: { [key: string]: any }): boolean; - function keystrokeToArray(lang: { [key: string]: any }, keystroke: number): { display: string[], aria: string[] }; - function keystrokeToString(lang: { [key: string]: any }, keystroke: number): { display: string, aria: string }; - function ltrim(str: string): string; - function normalizeCssText(styleText: string, nativeNormalize: boolean): string; - function normalizeHex(styleText: string): string; - function objectCompare(left: { [key: string]: any }, right: { [key: string]: any }, onlyLef?: boolean): boolean; - function objectKeys(obj: { [key: string]: any }): string[]; - function override(originalFunction: T, functionBuilder: (originalFunction: T) => T): T; - function parseCssText(styleText: string, normalize?: boolean, nativeNormalize?: boolean): { [key: string]: any }; - function prototypedCopy(source: { [key: string]: any }): { [key: string]: any }; - function removeFunction(ref: number): void; - function repeat(str: string, times: number): string; - function rtrim(str: string): string; - function search(array: T[], value: T | ((element: T) => boolean)): T; - function setCookie(name: string, value: string): void; - function setTimeout(func: Function, milliseconds?: number, scope?: { [key: string]: any }, args?: any, ownerWindow?: Window): number; - function transformPlainTextToHtml(text: string, etnerMode: number): string; - function trim(str: string): string; - function tryThese(fn: Function[]): any; - function writeCssText(styles: { [key: string]: any }, sort?: boolean): string; - - namespace array { - function every(array: T[], fn: (value: T, index: number, array: T[]) => boolean, thisArg?: { [key: string]: any }): boolean; - function filter(array: T[], fn: (value: T, index: number, array: T[]) => boolean, thisArg?: { [key: string]: any }): T[]; - function forEach(array: T[], fn: (value: T, index: number, array: T[]) => void, thisArg?: { [key: string]: any }): void; - function isArray(object: any): boolean; - function map(array: T[], fn: (value: T) => K, thisArg?: { [key: string]: any }): K[]; - function reduce(array: T[], fn: (accumulator: K, a: T, index: number, array: T[]) => K, initial: K, thisArg?: { [key: string]: any }): K; - } - - namespace object { - function findKey(obj: { [key: string]: any }, value: any): string; - function merge(obj1: { [key: string]: any }, obj2: { [key: string]: any }): { [key: string]: any }; - } - - namespace style { - namespace parse { - function background(value: string): { color: string, unprocessed: string}; - function border(value: string): { width: string, style: string, color: string }; - function margin(value: string): { top: number, right: number, bottom: number, left: number }; - } - } - } - - class ui extends event { - constructor(editor: editor); - add(name: string, type: { [key: string]: any }, definition: { [key: string]: any }): void; - addButton(name: string, definition: buttonDefinition): void; - addHandler(type: { [key: string]: any }, handler: { [key: string]: any }): void; - addRichCombo(name: string, definition: { [key: string]: any }): void; - addToolbarGroup(name: string, previous: number | string, subgroupOf?: string): void; - create(name: string): { [key: string]: any }; - get(name: string): { [key: string]: any }; - space(name: string): dom.element; - spaceId(name: string): string; - } - - namespace ui { - namespace dialog { - class button extends uiElement { - constructor(dialog: dialog, elementDefinition: definitions.button, htmlList: any[]); - - accessKeyDown(): void; - accessKeyUp(): void; - click(): any; - } - - class checkbox extends uiElement { - constructor(dialog: dialog, elementDefinition: definitions.checkbox, htmlList: any[]); - - accessKeyUp(): void; - getValue(): boolean; - setValue(checked: boolean, noChangeEvent: boolean): undefined; - } - - namespace definitions { - interface button { - label: string; - disabled?: boolean; - } - - interface checkbox { - checked?: boolean; - validate?: () => boolean; - label?: string; - } - - interface fieldSet { - label?: string; - children: any[]; - } - - interface file { - validate?: () => boolean; - } - - interface fileButton { - for: string; - validate?: () => boolean; - } - - interface hbox { - widths?: string[]; - height?: string; - padding?: string; - align?: string; - } - - interface html { - html: string; - } - - interface iframeElement { - src: string; - width: string; - height: string; - onContentLoad?: () => void; - } - - interface labeledElement { - label: string; - labelLayout?: 'horizontal' | 'vertical'; - widths?: [ string, string ]; - role?: string; - includeLabel?: boolean; - } - - interface radio { - default: any; - validate?: () => boolean; - items: ([string, string] | [string])[]; - } - - interface select { - default: any; - validate?: () => boolean; - items: ([string, string] | [string])[]; - multiple?: boolean; - size?: number; - } - - interface textarea { - rows?: number; - cols?: number; - default?: string; - validate?: () => boolean; - } - - interface textInput { - default?: string; - validate?: () => boolean; - maxLength?: number; - size?: string; - } - - interface uiElement { - id: string; - type: number; - title?: string; - hidden?: boolean; - className?: string; - style?: string; - accessKey?: string; - } - - interface vbox { - width?: string; - heights?: string[]; - align?: string; - padding?: string; - expand?: boolean; - } - } - - class fieldset extends uiElement { - constructor(dialog: dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: definitions.fieldSet); - } - - - class file extends ui.dialog.labeledElement { - constructor(dialog: dialog, elementDefinition: definitions.file, htmlList: any[]); - - getAction(): string; - registerEvents(definition: { [key: string]: any }): file; - reset(): void; - setInitValue(): void; - submit(): file; - } - - - class fileButton extends button { - constructor(dialog: dialog, elementDefinition: definitions.fileButton, htmlList: any[]); - } - - - class hbox extends uiElement { - constructor(dialog: dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: definitions.hbox); - - getChild(indices: number): ui.dialog.uiElement; - getChild(indices: number[]): ui.dialog.uiElement[]; - } - - - class html extends uiElement { - constructor(dialog: dialog, elementDefinition: definitions.html, htmlList: any[]); - - } - - - class iframeElement extends uiElement { - - } - - - class labeledElement extends uiElement { - constructor(dialog: dialog, elementDefinition: definitions.labeledElement, htmlList: any[], contentHtml: () => string); - - getLabel(): string; - setlabel(label: string): ui.dialog.labeledElement; - } - - - class radio extends ui.dialog.labeledElement { - constructor(dialog: dialog, elementDefinition: definitions.radio, htmlList: any[]); - - accessKeyUp(): void; - getValue(): string; - setValue(value: string, noChangeEvent: boolean): undefined; - } - - - class select extends uiElement { - constructor(dialog: dialog, elementDefinition: definitions.select, htmlList: any[]); - - add(label: string, value?: string, indexedDB?: number): select; - clear(): select; - remove(index: number): select; - } - - - class textarea extends labeledElement { - constructor(dialog: dialog, elementDefinition: definitions.textarea, htmlList: any[]); - } - - - class textInput extends ui.dialog.labeledElement { - constructor(dialog: dialog, elementDefinition: definitions.textInput, htmlList: any[]); - - accessKeyUp(): void; - focus(): undefined; - getDirectionMarker(): string; - getValue(): string; - select(): void; - setDirectionMarker(dir: string): void; - setValue(value: string, noChangeEvent: boolean): textInput; - } - - class uiElement { - eventProcessors: any; - - constructor(dialog: dialog, elementDefinition: definitions.uiElement, htmlList: any[], nodeNameArg?: () => string | string, stylesArg?: () => { [key: string]: any } | { [key: string]: any }, attributesArg?: () => { [key: string]: any } | { [key: string]: any }, contentsArg?: () => { [key: string]: any } | string); // Not sure that the htmlList array type is right. - - accessKeyDown(dialog: dialog, key: string): void; - accessKeyUp(dialog: dialog, key: string): void; - disable(): void; - enable(): void; - focus(): ui.dialog.uiElement; - getDialog(): dialog; - getElement(): dom.element; - getInputElement(): dom.element; - getValue(): any; - isChanged(): boolean; - isEnabled(): boolean; - isFocusable(): boolean; - isVisible(): boolean; - registerEvents(definition: CKEDITOR.dialog.definition.uiElement): ui.dialog.uiElement; - selectParentTab(): ui.dialog.uiElement; - setValue(value: any, noChangeEvent: boolean): ui.dialog.uiElement; - } - - class vbox extends hbox { - constructor(dialog: dialog, childObjList: any[], childHtmlList: any[], htmlList: any[], elementDefinition: definitions.vbox); - } - } - - class balloonPanel { - activeShowListeners: { [id: number]: { removeListener: listenerRegistration }}; - editor: editor; - focusables: { [id: number]: dom.element }; - height: string; - parts: balloonPanel.parts; - rect: balloonPanel.rect; - showListeners: { [id: number]: () => listenerRegistration }; - templateDefinitions: balloonPanel.templateDefinitions; - templates: balloonPanel.templates; - triangleHeight: number; - triangleMinDistance: number; - triangleWidth: number; - width: number; - - activeShowListener(id: number): void; - activateShowListeners(): void; - addShowListener(listener: () => listenerRegistration): listenerRegistration; - attach(element: dom.element, options?: dom.element | boolean | { focusElement?: dom.element | boolean, show?: boolean }): void; - blur(): void; - build(): void; - deactivateShowListener(id: number): void; - deregisterFocusable(element: dom.element): void; - destroy(): void; - getHeight(): number; - getWidth(): number; - hide(): void; - move(top: number, left: number): void; - registerFocusable(element: dom.element): void; - removeShowListener(id: number): void; - resize(width: number, height: number): void; - setTitle(title: string): void; - setTriangle(side: 'left' | 'right' | 'top' | 'bottom'): void; - show(): void; - } - - namespace balloonPanel { - interface definition { - content?: string; - title?: string; - } - - interface templates { - close?: template; - content?: template; - panel?: template; - title?: template; - triangle?: template; - triangleInner?: template; - triangleOuter?: template; - } - - interface templateDefinitions { - close?: string; - content?: string; - panel?: string; - title?: string; - triangle?: string; - triangleInner?: string; - triangleOuter?: string; - } - - interface rect { - height?: number; - left?: number; - top?: number; - visible?: boolean; - width?: number; - } - - interface parts { - close?: dom.element; - content?: dom.element; - panel?: dom.element; - title?: dom.element; - triangle?: dom.element; - triangleInner?: dom.element; - triangleOuter?: dom.element; - } - } - - class balloonToolbar { - constructor(editor: editor, definition: { [key: string]: any }); - addItem(name: string, element: button | richCombo): void; - addItems(elements: { [itemName: string]: button | richCombo }): void; - deleteItem(name: string): void; - destroy(): void; - getItem(name: string): button | richCombo; - hide(): void; - refresh(): void; - show(): void; - } - - class button { - static readonly handler: handlerDefinition