RED.sidebar

侧边栏允许节点和插件添加自定义标签页。

RED.sidebar API

RED.sidebar.addTab( tab )

在侧边栏添加一个新标签页。

tab 定义是一个包含以下属性的对象:

属性 描述
id The unique id for this tab.
label The text to display on the sidebar tab. This should not be too long.
name The name of the tab displayed in the sidebar menu.
iconClass The FontAwesome 4 class of the icon to use. For example, "fa fa-database"
content The DOM element containing the content of the sidebar.
toolbar (optional) A DOM element to display in the sidebar toolbar when this tab is active.
enableOnEdit (optional) If set to true, this tab will be accessible whilst the edit dialog is open. Default: false.
action (optional) The name of a registered action used to display this tab. This allows the user to assign a keyboard shortcut to switch to the tab.

// The sidebar content
const content = $("<div>").css({"position":"relative","height":"100%"});

// (optional) A toolbar header for the sidebar
const header = $("<div>", {class:"red-ui-sidebar-header"}).appendTo(content);


RED.actions.add("my-custom-tab:show-custom-tab",function() {
    RED.sidebar.show("my-custom-tab");
});

RED.sidebar.addTab({
    id: "my-custom-tab",
    label: "custom",
    name: "My Custom Tab",
    iconClass: "fa fa-database",
    content: content,
    action: "my-custom-tab:show-custom-tab"
});

RED.sidebar.removeTab( id )

如果该标签页存在,则将其移除。

如果一个节点在其onpaletteadd函数中添加了一个标签页,它必须确保在onpaletteremove函数中调用此API来移除它。

RED.sidebar.removeTab("my-custom-tab");

RED.sidebar.show( id )

如果存在,在侧边栏中显示给定的标签页。

RED.sidebar.show("my-custom-tab")

RED.sidebar.containsTab( id )

如果侧边栏中存在该标签页,则返回 true

let debugExists = RED.sidebar.containsTab('my-custom-tab');