Fabricjs - new/updated definitions. Updated to latest 3.x (#36605)

This commit is contained in:
BradleyHill 2019-07-03 10:40:55 -05:00 committed by Ryan Cavanaugh
parent 97925867a8
commit 6fef8d046a
2 changed files with 44 additions and 16 deletions

View File

@ -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<Array<{ width: number, left: number, height: number, kernedWidth: number, deltaY: number }>>,
}
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<Number>
*/
__lineWidths: number[];
/**
* List of line heights
* @private
* @type Array<Number>
*/
__lineHeights: number[];
/**
* Contains characters bounding boxes for each line and char
* @private
* @type Array of char grapheme bounding boxes
*/
__charBounds?: Array<Array<{ width: number, left: number, height: number, kernedWidth: number, deltaY: number }>>;
/**
* 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

View File

@ -1,4 +1,4 @@
// Type definitions for FabricJS 2.6
// Type definitions for FabricJS 3.0
// Project: http://fabricjs.com/
// Definitions by: Oliver Klemencic <https://github.com/oklemencic>
// Joseph Livecchi <https://github.com/joewashear007>