Interface IToolbarBuilder
The toolbar builder helps you create Toolbar configurations for the UI. Note that it has a fluid API, and each method/use returns a fresh object with the updated configuration.
Inherited Members
Namespace: ToSic.Sxc.Edit
Assembly: ToSic.Sxc.dll
Syntax
[PublicApi]
public interface IToolbarBuilder : IHybridHtmlString, IHtmlString, IHasLog, INeedsDynamicCodeRoot
Remarks
Your code cannot construct this object by itself, as it usually needs additional information.
To get a ToolbarBuilder
, use the IToolbarService.
History
- Added in 2sxc 13
Methods
| Improve this Doc View SourceAdd(String[])
Add one or more rules according to the conventions of the js toolbar
Declaration
IToolbarBuilder Add(params string[] rules)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | rules |
Returns
Type | Description |
---|---|
IToolbarBuilder |
Remarks
History
- Added in 2sxc 13
Condition(Boolean)
Condition to apply if the toolbar would show, but maybe shouldn't. For example, you can prevent the toolbar from appearing if it's the Demo-Item.
For expensive conditions, use the overload which accepts a function.
Declaration
IToolbarBuilder Condition(bool condition)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | condition | true/false |
Returns
Type | Description |
---|---|
IToolbarBuilder |
Remarks
New in v14.04
Condition(Func<Boolean>)
Condition to apply if the toolbar would show, but maybe shouldn't. For example, you can prevent the toolbar from appearing if it's the Demo-Item.
This accepts a function to check the condition. It will only run if the toolbar would already show.
Declaration
IToolbarBuilder Condition(Func<bool> condition)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Boolean> | condition | function such as |
Returns
Type | Description |
---|---|
IToolbarBuilder |
Remarks
New in v14.04
Copy(Object, String, Object, Object, String)
Create a toolbar rule to copy an item. It needs the item which it will copy as a parameter.
Declaration
IToolbarBuilder Copy(object target, string noParamOrder = "Rule: All params must be named (https://r.2sxc.org/named-params)", object ui = null, object parameters = null, string context = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | target | The target object which is either an IEntity or an IDynamicEntity |
System.String | noParamOrder | |
System.Object | ui | Parameters for the UI, like |
System.Object | parameters | Parameters for the command. Can be a string, and can also be an object since v14.04 |
System.String | context | EXPERIMENTAL - not final |
Returns
Type | Description |
---|---|
IToolbarBuilder | A new toolbar builder which has been extended with this button |
Remarks
Added in v14.02
Metadata(Object, String, String, Object, Object, String)
Create an add metadata
rule to add or edit metadata to the specified object and using the content-type specified here.
Declaration
IToolbarBuilder Metadata(object target, string contentTypes = null, string noParamOrder = "Rule: All params must be named (https://r.2sxc.org/named-params)", object ui = null, object parameters = null, string context = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | target | The target object which should receive metadata. Must support IHasMetadata |
System.String | contentTypes | Name of one or more content-types for which to generate the button(s). For many, use comma |
System.String | noParamOrder | |
System.Object | ui | Parameters for the UI, like |
System.Object | parameters | Parameters for the command. Can be a string, and can also be an object since v14.04 |
System.String | context | EXPERIMENTAL - not final |
Returns
Type | Description |
---|---|
IToolbarBuilder | A new toolbar builder which has been extended with this button |
Remarks
History
- Added in 2sxc 13
- contentTypes changed from one to many in v14
- contentTypes can also have
*
orSomeType,*
in v14 - contentTypes can also be optional, in which case it behaves as if it was
*
in v14 - if no config is found, it will not add a metadata-button - parameter context added in 2sxc 14 - still WIP/experimental
- changed ui and parameters to support object in v14.04
Modify(String, String, Object, Object)
Declaration
[WorkInProgressApi("still WIP")]
IToolbarBuilder Modify(string name, string noParamOrder = "Rule: All params must be named (https://r.2sxc.org/named-params)", object ui = null, object parameters = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The command name. See CommandNames |
System.String | noParamOrder | |
System.Object | ui | Parameters for the UI, like |
System.Object | parameters | Parameters for the command. Can be a string, and can also be an object since v14.04 |
Returns
Type | Description |
---|---|
IToolbarBuilder |
Remarks
- new in 14.04 WIP
Remove(String[])
Remove buttons from the toolbar.
Usually in combination with the Default
toolbar which already has many buttons, for eg to remove the layout
button.
Declaration
[WorkInProgressApi("still WIP")]
IToolbarBuilder Remove(params string[] names)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | names | One or more command names. See CommandNames |
Returns
Type | Description |
---|---|
IToolbarBuilder |
Settings(String, String, String, String, String, String, Object, Object)
Add a settings
rule to configure what the toolbar should look like. See Toolbar Settings
Declaration
IToolbarBuilder Settings(string noParamOrder = "Rule: All params must be named (https://r.2sxc.org/named-params)", string show = null, string hover = null, string follow = null, string classes = null, string autoAddMore = null, object ui = null, object parameters = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | noParamOrder | |
System.String | show | |
System.String | hover | |
System.String | follow | |
System.String | classes | |
System.String | autoAddMore | |
System.Object | ui | Parameters for the UI, like |
System.Object | parameters | Parameters for the command - doesn't really have an effect on Settings, but included for consistency |
Returns
Type | Description |
---|---|
IToolbarBuilder | A new toolbar builder which has been extended with this settings-rule |
Remarks
History
- Added in 2sxc 13
Target(Object)
Set the main target of this toolbar.
Declaration
IToolbarBuilder Target(object target)
Parameters
Type | Name | Description |
---|---|---|
System.Object | target |
Returns
Type | Description |
---|---|
IToolbarBuilder |
Remarks
New in v14.04
ToString()
Converts the configuration to a json-string according to the JS-Toolbar specs.
Declaration
string ToString()
Returns
Type | Description |
---|---|
System.String |