I have created a plugin and I want the options of the editor of my plugin to appear in sections and subsections.
For example
- Section
- subsection
- option1 (Radio Button)
- option2 (Text box)
- option3 (Boolean Switchto be visible only if the value inside the textbox in option 2 is ‘Hello’)
- subsection
For the Section, I am using category
property. For the subsection I am using addNestedOptions.
Now I am trying to utilize the showIf
function inside the the addNestedOptions
as follows:
export const plugin = new PanelPlugin<SimpleOptions>(SimplePanel).setPanelOptions((builder) => {
return builder.addNestedOptions({
category: ['Section'],
path: 'typesofsection1',
build: (builder) => {
builder
.addTextInput({
path: 'type1',
name: 'Option1',
description: '',
defaultValue: '',
category: ['subsection'],
})
.addTextInput({
path: 'type2',
name: 'Option2',
description: '',
defaultValue: '',
category: ['subsection'],
})
.addBooleanSwitch({
path: 'type3',
name: 'Option3',
defaultValue: false,
category: ['subsection'],
showIf: (cfg) => cfg.typesofsection1.type2=== 'Hello',
})
},
});
});
Now my problem is with the last line. When I move the whole addBooleanSwitch
block outside the addNestedOptions
it works fine, but with a hierarchy where subsection is on the same level as Section. But when it is like shown above, I get the following error
Object is of type 'unknown'.ts(2571)