Introduction

Important: This module is available only in Wix Blocks. Wix Blocks is an editor for building Wix apps.

The Editor API is used within the code of panels built with the Blocks Panel Builder. It enables your panel to interact with the Wix editors by removing or restoring widget elements, opening Dashboard panels, and more. To use the Editor API, import wixEditor from the wix-editor module:

Copy
Did this help?

getCurrentViewport( )


Gets the viewport currently selected in the Editor.

The getCurrentViewport() function returns a Promise that resolves to an object containing details about the currently selected viewport. To use this function on an inner (nested) widget, use getScopedWixEditor().

Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<Viewport>
Get the current viewport
JavaScript
Did this help?

getScopedWixEditor( )


Gets the wix-editor module scoped of an inner (nested) widget.

The getScopedWixEditor() function lets you use wix-editor functions on inner (nested) widgets. It receives a selector of an inner widget and returns a promise that resolves with an object representing the scope of the inner widget.

Method Declaration
Copy
Method Parameters
SelectorstringRequired

A string of one or more nested widget selectors, which can include a few levels of nesting from outer to inner, separated by spaces. For example: ("#nestedWidget1"), or ("#nestedWidget1 #nestedWidget2").

Returns
Return Type:Promise<object>
Removes an element in an inner (nested) widget
JavaScript
Did this help?

isRemoved( )


Checks if an element is removed from the widget.

The isRemoved() function returns a Promise that resolves to true if the element is removed.

The element selector is a string with the hash symbol (#) followed by the ID of the item you want to select (e.g. "#myElement"). To use this function on an inner (nested) widget, use getScopedWixEditor().

Method Declaration
Copy
function isRemoved(selector: string): Promise<void>;
Method Parameters
selectorstringRequired

An element selector.

Check if an element is removed
JavaScript
import wixEditor from "wix-editor"; // ... wixEditor.isRemoved("#title").then((isRemoved) => { // Your code that uses the 'isRemoved' value goes here });
Did this help?