From 65c4c9358b85c8ebb56cab394e9eb7313590f904 Mon Sep 17 00:00:00 2001 From: Bradley Hill Date: Fri, 31 Aug 2018 12:35:33 -0500 Subject: [PATCH] Add ITextOptions underline, overline, linethrough. Add Textbox object. --- types/fabric/fabric-impl.d.ts | 97 ++++++++++++++++++++++++++++++++++- types/fabric/index.d.ts | 1 + 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 783a4f41f7..6749f6b47c 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -3081,8 +3081,27 @@ interface ITextOptions extends IObjectOptions { fontFamily?: string; /** * Text decoration Possible values?: "", "underline", "overline" or "line-through". + * Feels like this has been deprecated in favor of underline, overline, linethrough props */ textDecoration?: string; + /** + * Text decoration underline. + * @type Boolean + * @default + */ + underline?: boolean; + /** + * Text decoration overline. + * @type Boolean + * @default + */ + overline?: boolean; + /** + * Text decoration linethrough. + * @type Boolean + * @default + */ + linethrough?: boolean; /** * Text alignment. Possible values?: "left", "center", or "right". */ @@ -3190,6 +3209,33 @@ export class Text extends Object { * @param textDecoration Text decoration */ setTextDecoration(textDecoration: string): Text; + /** + * Retrieves object's underline + */ + getUnderline(): boolean; + /** + * Sets object's underline + * @param underline Text underline + */ + setUnderline(underline: boolean): Text; + /** + * Retrieves object's overline + */ + getOverline(): boolean; + /** + * Sets object's overline + * @param overline Text overline + */ + setOverline(overline: boolean): Text; + /** + * Retrieves object's linethrough + */ + getLinethrough(): boolean; + /** + * Sets object's linethrough + * @param linethrough Text linethrough + */ + setLinethrough(linethrough: boolean): Text; /** * Retrieves object's fontStyle */ @@ -3311,6 +3357,52 @@ interface IITextOptions extends IObjectOptions, ITextOptions { */ caching?: boolean; } +export interface Textbox extends IText {} +export class Textbox extends IText { + /** + * Constructor + * @param text Text string + * @param [options] Options object + */ + constructor(text: string, options?: IITextOptions); + /** + * Detect if the text line is ended with an hard break + * text and itext do not have wrapping, return false + * @param {Number} lineIndex text to split + * @return {Boolean} + */ + isEndOfWrapping(lineIndex: number): boolean; + /** + * Get minimum width of text box + * @return {Number} + */ + getMinWidth(): number; + /** + * Selects entire text + * @return {fabric.Text} thisArg + * @chainable + */ + selectAll(): Textbox; + /** + * Selects a line based on the index + * @param {Number} selectionStart Index of a character + * @return {fabric.IText} thisArg + * @chainable + */ + selectLine(selectionStart: number): Textbox; + /** + * Enters editing state + * @return {fabric.Textbox} thisArg + * @chainable + */ + enterEditing(): Textbox; + /** + * Exits from editing state + * @return {fabric.Textbox} thisArg + * @chainable + */ + exitEditing(): Textbox; +} export interface IText extends Text, IITextOptions { } export class IText extends Object { /** @@ -3320,9 +3412,10 @@ export class IText extends Object { */ constructor(text: string, options?: IITextOptions); /** - * Returns true if object has no styling + * Returns true if object has no styling or no styling in a line + * @param {Number} lineIndex , lineIndex is on wrapped lines. */ - isEmptyStyles(): boolean; + isEmptyStyles(lineIndex: number): boolean; render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; /** * Returns object representation of an instance diff --git a/types/fabric/index.d.ts b/types/fabric/index.d.ts index 76ed1ab054..e8d31aef56 100644 --- a/types/fabric/index.d.ts +++ b/types/fabric/index.d.ts @@ -6,6 +6,7 @@ // Tiger Oakes // Brian Martinson // Rogerio Teixeira +// Bradley Hill // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 export import fabric = require("./fabric-impl");