From 6fef8d046aa772462895a298dd315979b38f964f Mon Sep 17 00:00:00 2001 From: BradleyHill Date: Wed, 3 Jul 2019 10:40:55 -0500 Subject: [PATCH] Fabricjs - new/updated definitions. Updated to latest 3.x (#36605) --- types/fabric/fabric-impl.d.ts | 58 ++++++++++++++++++++++++++--------- types/fabric/index.d.ts | 2 +- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 3b751a16f9..e4e6fd644f 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -1934,6 +1934,11 @@ export class Canvas { * @param {CanvasRenderingContext2D} ctx Context to render controls on */ drawControls(ctx: CanvasRenderingContext2D): void; + /** + * @private + * @return {Boolean} true if the scaling occurred + */ + _setObjectScale(localMouse: Point, transform: any, lockScalingX: boolean, lockScalingY: boolean, by: 'x' | 'y' | undefined, lockScalingFlip: boolean, _dim: Point): boolean; static EMPTY_JSON: string; /** @@ -3574,11 +3579,18 @@ export class Object { * @return {Boolean} true to cancel selection */ onDeselect(options: { e?: Event, object?: Object }): boolean; + /** + * This callback function is called every time _discardActiveObject or _setActiveObject + * try to to deselect this object. If the function returns true, the process is cancelled + * @param {Object} [options] options sent from the upper functions + * @param {Event} [options.e] event if the process is generated by an event + */ + onDeselect(options: { e?: Event; object?: fabric.Object }): boolean; /** * This callback function is called every time _discardActiveObject or _setActiveObject * try to to select this object. If the function returns true, the process is cancelled */ - onSelect(): void; + onSelect(options: { e?: Event }): boolean; /** * Returns svg clipPath representation of an instance * @param {Function} [reviver] Method for further parsing of svg representation. @@ -3933,12 +3945,6 @@ interface TextOptions extends IObjectOptions { * @type Array */ stateProperties?: string[]; - /** - * @private - * Contains characters bounding boxes for each line and char - * @type Array of char grapheme bounding boxes - */ - __charBounds?: Array>, } export interface Text extends TextOptions { } export class Text extends Object { @@ -3973,12 +3979,24 @@ export class Text extends Object { * @type RegExp */ _reSpaceAndTab: RegExp; + /** + * List of line widths + * @private + * @type Array + */ + __lineWidths: number[]; /** * List of line heights * @private * @type Array */ __lineHeights: number[]; + /** + * Contains characters bounding boxes for each line and char + * @private + * @type Array of char grapheme bounding boxes + */ + __charBounds?: Array>; /** * Text Line proportion to font Size (in pixels) * @private @@ -4241,6 +4259,16 @@ export class Text extends Object { * @param {Number} lineHeight Height of the line */ _renderChar(method: string, ctx: CanvasRenderingContext2D, lineIndex: number, charIndex: number, _char: string, left: number, top: number): void; + /** + * @private + * @param {String} method Method name ("fillText" or "strokeText") + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {Array} line Text to render + * @param {Number} left Left position of text + * @param {Number} top Top position of text + * @param {Number} lineIndex Index of a line in a text + */ + _renderTextLine(method: string, ctx: CanvasRenderingContext2D, line: string[], left: number, top: number, lineIndex: number): void; /** * @private */ @@ -4481,12 +4509,12 @@ export class IText extends Text { * @chainable */ selectLine(selectionStart: number): IText; - /** - * Enters editing state - * @return {fabric.IText} thisArg - * @chainable - */ - enterEditing(): IText; + /** + * Enters editing state + * @return {fabric.IText} thisArg + * @chainable + */ + enterEditing(e?: MouseEvent): IText; /** * Initializes "mousemove" event handler */ @@ -4810,9 +4838,9 @@ export class Textbox extends IText { * _wrapLine(). * @param {Array} lines The string array of text that is split into lines * @param {Number} desiredWidth width you want to wrap to - * @returns {Array} Array of lines + * @returns {Array} Array of grapheme lines */ - _wrapText(lines: string[], desiredWidth: number): string[]; + _wrapText(lines: string[], desiredWidth: number): string[][]; /** * Style objects for each line * Generate an object that translates the style object so that it is diff --git a/types/fabric/index.d.ts b/types/fabric/index.d.ts index 7444f481b8..f423c265e6 100644 --- a/types/fabric/index.d.ts +++ b/types/fabric/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for FabricJS 2.6 +// Type definitions for FabricJS 3.0 // Project: http://fabricjs.com/ // Definitions by: Oliver Klemencic // Joseph Livecchi