Interface IEditService
Contains status and commands to configure the in-page editing system.
You will never create this yourself, as get this automatically in Razor or WebAPIs on an object called Edit
.
Inherited Members
Namespace: ToSic.Sxc.Services
Assembly: ToSic.Sxc.dll
Syntax
[PublicApi_Stable_ForUseInYourCode]
public interface IEditService : IInPageEditingSystem, IHasLog, INeedsDynamicCodeRoot
Remarks
History
- First version created ca. v2 - originally as
ToSic.Sxc.Web.IInPageEditEditingHelper
- Moved to
ToSic.Sxc.Services.IEditService
in v13.05
Properties
| Improve this Doc View SourceEnabled
If editing is enabled or not
Declaration
bool Enabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if enabled, false if not. |
Methods
| Improve this Doc View SourceAttribute(String, Object)
Generate an HTML attribute by converting the value to JSON
- but only in edit mode
Declaration
IHybridHtmlString Attribute(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | the attribute name, used for ...= |
System.Object | value | the attribute value, used for ="..." |
Returns
Type | Description |
---|---|
IHybridHtmlString | A string but as HtmlString, so it can be used with @Attribute(...) |
Attribute(String, String)
Generate an HTML attribute by converting the value to JSON
- but only in edit mode
Declaration
IHybridHtmlString Attribute(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | the attribute name, used for ...= |
System.String | value | the attribute value, used for ="..." |
Returns
Type | Description |
---|---|
IHybridHtmlString | A string but as HtmlString, so it can be used with @Attribute(...) |
ContextAttributes(IDynamicEntity, String, String, String, Nullable<Guid>, String, Int32)
Get html-attributes to mark the current context
these will be added to a wrapper tag (usually a div)
so that in-page editing knows what the context is
Please read more about Inner Content (Content Within Other Content)
Declaration
IHybridHtmlString ContextAttributes(IDynamicEntity target, string noParamOrder = "Params must be named (https://r.2sxc.org/named-params)", string field = null, string contentType = null, Guid? newGuid = default(Guid? ), string apps = null, int max = 100)
Parameters
Type | Name | Description |
---|---|---|
IDynamicEntity | target | The content-item for which the new context should be. This item usually has a field which has Inner Content (Content Within Other Content) |
System.String | noParamOrder | |
System.String | field | the field of this content-item, which contains the inner-content-items |
System.String | contentType | type name used for 'new' items in a toolbar - usually for inner-content and list-contexts |
System.Nullable<System.Guid> | newGuid | the guid of a new item - use null for auto-generate |
System.String | apps | Restrict the apps which can be added to this placeholder |
System.Int32 | max | Limit the amount of content-blocks that can be added to this placeholder |
Returns
Type | Description |
---|---|
IHybridHtmlString | An IHybridHtmlString object containing an html-attribute to add to the wrapper of the inner content |
Remarks
History
- Introduced in 2sxc 8.4
- Enhanced with apps and max in 10.27
Enable(String, Nullable<Boolean>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Boolean>)
Ensure that the UI will load the correct assets to enable editing. See Method in C# Razor (Deprecated)
Declaration
string Enable(string noParamOrder = "Params must be named (https://r.2sxc.org/named-params)", bool? js = default(bool? ), bool? api = default(bool? ), bool? forms = default(bool? ), bool? context = default(bool? ), bool? autoToolbar = default(bool? ), bool? styles = default(bool? ))
Parameters
Type | Name | Description |
---|---|---|
System.String | noParamOrder | |
System.Nullable<System.Boolean> | js | optional, default false. automatically true if |
System.Nullable<System.Boolean> | api | optional, default false. automatically true, if |
System.Nullable<System.Boolean> | forms | optional, default false. |
System.Nullable<System.Boolean> | context | optional, default false. |
System.Nullable<System.Boolean> | autoToolbar | optional, default false. |
System.Nullable<System.Boolean> | styles | optional, default false. |
Returns
Type | Description |
---|---|
System.String | null - but we wanted to make sure it returns something, so you can use it in razor like @Edit.Enable(...) |
Remarks
History
- Introduced in 2sxc 9.30
- Enhanced with parameter jsApi in 10.20
- Being deprecated in 12.02, as you should now use the IPageService instead for most of these features
TagToolbar(Object, String, String, String, Object, Object, Object, Object)
Generate a toolbar attribute inside an html-tag
See also @HowTo.Razor.Edit.Toolbar
Declaration
IHybridHtmlString TagToolbar(object target = null, string noParamOrder = "Params must be named (https://r.2sxc.org/named-params)", string actions = null, string contentType = null, object condition = null, object prefill = null, object settings = null, object toolbar = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | target | The optional content-item this toolbar is for. Can be null. If the first parameter is a IToolbarBuilder then all other parameters will be ignored. |
System.String | noParamOrder | |
System.String | actions | List of actions on this toolbar. If null, will use default actions for this item. If provided, must be comma-separated action-names - see CMS Commands in JavaScript. |
System.String | contentType | Content-type of this toolbar, used when it has |
System.Object | condition | Condition will make that no toolbar is created, if it's 0, false or "false" |
System.Object | prefill | Allows a |
System.Object | settings | Toolbar settings controlling hover etc. |
System.Object | toolbar | Full manual toolbar configuration. Setting this will cause If the the |
Returns
Type | Description |
---|---|
IHybridHtmlString | If the user is an editor, it returns the attribute containing all the toolbar configuration. |
Remarks
History
- Added in 2sxc 9.40
condition
added in 2sxc 12.05- option to just use a ToolbarBuilder as first parameter or
toolbar
parameter added in v13 - this will skip all other parameters
Toolbar(Object, String, String, String, Object, Object, Object, Object)
Generate a toolbar tag - must be used in normal html, not as an attribute.
See also and Methods in Razor / .net
Declaration
IHybridHtmlString Toolbar(object target = null, string noParamOrder = "Params must be named (https://r.2sxc.org/named-params)", string actions = null, string contentType = null, object condition = null, object prefill = null, object settings = null, object toolbar = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | target | The content-item this toolbar is for, can be null. If the first parameter is a IToolbarBuilder then all other parameters will be ignored. |
System.String | noParamOrder | |
System.String | actions | List of actions on this toolbar. If null, will use default actions for this item. If provided, must be comma-separated action-names - see CMS Commands in JavaScript. |
System.String | contentType | Content-type of this toolbar, used when it has |
System.Object | condition | Condition will make that no toolbar is created, if it's 0, false or "false" |
System.Object | prefill | Allows a |
System.Object | settings | Toolbar settings controlling hover etc. |
System.Object | toolbar | Full manual toolbar configuration. Setting this will cause If the the |
Returns
Type | Description |
---|---|
IHybridHtmlString | If the user is an editor, it returns HTML UL tag containing all the toolbar configuration. |
Remarks
History
- Added in 2sxc 8.04
condition
added in 2sxc 12.05- option to just use a ToolbarBuilder as first parameter or
toolbar
parameter added in v13 - this will skip all other parameters