From e0963ebd730d723c5412765090edc97394a0eade Mon Sep 17 00:00:00 2001 From: Ian Leue Date: Fri, 21 Oct 2022 05:28:49 -0400 Subject: [PATCH] Some typescript updates (#4678) --- index.d.ts | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/index.d.ts b/index.d.ts index cf64ecfc4..4cbb46f5c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -23,6 +23,7 @@ declare namespace Backbone { remove(model: {} | TModel): TModel; remove(models: Array<{} | TModel>): TModel[]; reset(models?: Array<{} | TModel>): TModel[]; + each(callback: (item: TModel) => void); } interface GenericModel extends Model<{}> { } @@ -88,7 +89,9 @@ declare namespace grapesjs { /** By default Grapes injects base CSS into the canvas. For example, it sets body margin to 0 * and sets a default background color of white. This CSS is desired in most cases. * use this property if you wish to overwrite the base CSS to your own CSS. This is most - * useful if for example your template is not based off a document with 0 as body margin. */ + * useful if for example your template is not based off a document with 0 as body margin. + * @deprecated in favor of `config.canvas.frameStyle` + */ baseCss?: string; /** CSS that could only be seen (for instance, inside the code viewer) */ @@ -255,6 +258,8 @@ declare namespace grapesjs { keepUnusedStyles?: 0; layerManager?: LayerManagerConfig; + + parser?: ParserConfig; } interface AssetManagerConfig { @@ -396,6 +401,7 @@ declare namespace grapesjs { customBadgeLabel?: Function; autoscrollLimit?: number; notTextable?: Array; + frameStyle?: string; } interface StyleManagerConfig { @@ -534,6 +540,7 @@ declare namespace grapesjs { statesLabel?: string; selectedLabel?: string; states?: Array; + componentFirst?: boolean; } interface DeviceManagerConfig { @@ -627,6 +634,10 @@ declare namespace grapesjs { extend?: any; } + interface ParserConfig { + optionsHtml?: object; + } + function init(config: EditorConfig): Editor; interface Trait extends Backbone.Model { @@ -918,11 +929,13 @@ declare namespace grapesjs { * @param [opts.avoidUpdateStyle = false] - If the HTML string contains styles, * by default, they will be created and, if already exist, updated. When this option * is true, styles already created will not be updated. + * @param [opts.at] - If provided, an index to insert these components at. */ addComponents( components: object[] | any | string, opts?: { avoidUpdateStyle?: boolean; + at?: number; } ): Component[]; /** @@ -1244,6 +1257,8 @@ declare namespace grapesjs { * const strHtml = editor.html`Escaped ${unsafeStr}, unescaped $${safeStr}`; */ html(literals: string[], substs: string[]): string; + + getModel(): Backbone.Model; } type GrapesEvent = @@ -1335,7 +1350,7 @@ declare namespace grapesjs { | `stop:${string}` | `abort:${string}`; - type GeneralEvent = 'canvasScroll' | 'undo' | 'redo' | 'load'; + type GeneralEvent = 'canvasScroll' | 'undo' | 'redo' | 'load' | 'update'; /** * You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object](https://github.com/artf/grapesjs/blob/master/src/asset_manager/config/config.js) @@ -1641,12 +1656,12 @@ declare namespace grapesjs { * const block = blockManager.get('BLOCK_ID'); * blockManager.remove(block); */ - remove(): any; + remove(block: object | string): any; /** * Get all available categories. * It's possible to add categories only within blocks via 'add()' method */ - getCategories(): any[] | Backbone.Collection>; + getCategories(): Backbone.Collection>; /** * Return the Blocks container element */ @@ -2306,7 +2321,7 @@ declare namespace grapesjs { * * [Component]: component.html */ - interface Component extends Backbone.Model { + interface Component extends Backbone.Model, Styleable { view?: ComponentView; /** @@ -4013,7 +4028,7 @@ declare namespace grapesjs { * const device = deviceManager.get('some-id'); * deviceManager.select(device); */ - select(): void; + select(device: string | any): void; /** * Get the selected device * @example @@ -4419,7 +4434,7 @@ declare namespace grapesjs { * // Remove by selector * css.remove('.my-cls-2'); */ - remove(): any; + remove(toRemove: object | string): any; /** * Remove all rules */