Here’s an example of a custom Apex class extending the VisualEditor.DynamicPickList class. It includes VisualEditor.DesignTimePageContext to define a picklist value that is available only if the page type is HomePage.
global class MyCustomPickList extends VisualEditor.DynamicPickList{ VisualEditor.DesignTimePageContext context; global MyCustomPickList(VisualEditor.DesignTimePageContext context) { this.context = context; } global override VisualEditor.DataRow getDefaultValue(){ VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('red', 'RED'); return defaultValue; } global override VisualEditor.DynamicPickListRows getValues() { VisualEditor.DataRow value1 = new VisualEditor.DataRow('red', 'RED'); VisualEditor.DataRow value2 = new VisualEditor.DataRow('yellow', 'YELLOW'); VisualEditor.DynamicPickListRows myValues = new VisualEditor.DynamicPickListRows(); myValues.addRow(value1); myValues.addRow(value2); if (context.pageType == 'HomePage') { VisualEditor.DataRow value3 = new VisualEditor.DataRow('purple', 'PURPLE'); myValues.addRow(value3); } return myValues; } }
The following are properties for DesignTimePageContext.
public String entityName {get; set;}
Type: String