diff --git a/index.d.ts b/index.d.ts index 28d86cb59..80a1ca6c2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -250,6 +250,8 @@ declare namespace grapesjs { /** Keep unused styles within the editor **/ keepUnusedStyles?: 0; + + layerManager?: LayerManagerConfig; } interface AssetManagerConfig { @@ -424,6 +426,92 @@ declare namespace grapesjs { deviceLabel?: string; } + interface LayerManagerScrollLayersConfig { + behavior?: string; + block?: string; + } + + interface LayerManagerScrollCanvasConfig { + behavior?: string; + block?: string; + } + + interface LayerManagerConfig { + /** Specify the element to use as a container, string (query) or HTMLElement + * With the empty value, nothing will be rendered */ + appendTo?: HTMLElement | string; + + /** Scroll to selected component in Layers when it's selected in Canvas + * true, false or `scrollIntoView`-like options */ + scrollLayers?: number | boolean | LayerManagerScrollLayersConfig; + + /** Style prefix */ + stylePrefix?: string; + + /** Enable/Disable globally the possibility to sort layers */ + sortable?: boolean; + + /** Enable/Disable globally the possibility to hide layers */ + hidable?: boolean; + + /** Hide textnodes */ + hideTextnode?: boolean; + + /** Indicate a query string of the element to be selected as the root of layers. + * By default the root is the wrapper */ + root?: string; + + /** Indicates if the wrapper is visible in layers */ + showWrapper?: boolean; + + /** Show hovered components in canvas */ + showHover?: boolean; + + /** Scroll to selected component in Canvas when it's selected in Layers + * true, false or `scrollIntoView`-like options, + * `block: 'nearest'` avoids the issue of window scrolling */ + scrollCanvas?: boolean | LayerManagerScrollCanvasConfig; + + /** Highlight when a layer component is hovered */ + highlightHover?: boolean; + + /** + * WARNING: Experimental option + * A callback triggered once the component layer is initialized. + * Useful to trigger updates on some component prop change. + * @example + * onInit({ component, render, listenTo }) { + * listenTo(component, 'change:some-prop', render); + * }; + */ + onInit?: () => any; + + /** + * WARNING: Experimental option + * A callback triggered once the component layer is rendered. + * A callback useful to update the layer DOM on some component change + * @example + * onRender({ component, el }) { // el is the DOM of the layer + * if (component.get('some-prop')) { + * // do changes using the `el` DOM + * } + * } + */ + onRender?: () => any; + + /** + * Extend Layer view object (view/ItemView.js) + * @example + * extend: { + * setName(name) { + * // this.model is the component of the layer + * this.model.set('another-prop-for-name', name); + * }, + * }, + */ + extend?: any; + } + function init(config: EditorConfig): Editor; interface Trait extends Backbone.Model {