• Basics
  • Abyss
  • Web APIs
  • C# & Razor
  • .net API
  • JS & TS API

    Show / Hide Table of Contents

    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
    IHasLog.Log
    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 Source

    Enabled

    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 Source

    Attribute(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(...)

    | Improve this Doc View Source

    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(...)

    | Improve this Doc View Source

    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

    see Convention: Named Parameters

    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

    1. Introduced in 2sxc 8.4
    2. Enhanced with apps and max in 10.27
    | Improve this Doc View Source

    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

    see Convention: Named Parameters

    System.Nullable<System.Boolean> js

    optional, default false. automatically true if api or forms is true
    Will add the basic JS APIs ($2sxc) usually for enabling WebApi calls from your JS code.
    added in v10.20

    System.Nullable<System.Boolean> api

    optional, default false. automatically true, if forms is true
    If JS etc. should be included to enable editing API - ensures JavaScripts are loaded enabling commands to run

    System.Nullable<System.Boolean> forms

    optional, default false.
    Ensures JavaScripts are loaded enabling forms to open

    System.Nullable<System.Boolean> context

    optional, default false.
    If context (In-Page Editing Context (technical)) should be added, to ensure in-instance data editing

    System.Nullable<System.Boolean> autoToolbar

    optional, default false.
    Disables the automatic generation of a toolbar (this is important, as there usually won't be a toolbar in public pages, which would then trigger the fallback-toolbar to be generated)

    System.Nullable<System.Boolean> styles

    optional, default false.
    Ensures styles to be loaded, which would be necessary for the standard toolbars to look right

    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

    1. Introduced in 2sxc 9.30
    2. Enhanced with parameter jsApi in 10.20
    3. Being deprecated in 12.02, as you should now use the IPageService instead for most of these features
    | Improve this Doc View Source

    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.
    Usually a Dynamic Entity Objects or a Entity Objects

    If the first parameter is a IToolbarBuilder then all other parameters will be ignored.

    System.String noParamOrder

    see Convention: Named Parameters

    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 new or add buttons. This allows you to create a button for a new "Category" and another button for a new "BlogPost" etc.

    System.Object condition

    Condition will make that no toolbar is created, if it's 0, false or "false"

    System.Object prefill

    Allows a new dialog to receive values as a prefill. For example to already specify a date, title, category, etc.
    It's a dynamic object, see also the JS documentation on the prefill.

    System.Object settings

    Toolbar settings controlling hover etc.
    See Toolbar Settings

    System.Object toolbar

    Full manual toolbar configuration. Setting this will cause actions to be ignored.
    See In-Page Edit-Item Toolbars and Buttons

    If the the toolbar is a IToolbarBuilder then other parameters except for the target will be ignored.

    Returns
    Type Description
    IHybridHtmlString

    If the user is an editor, it returns the attribute containing all the toolbar configuration.

    Remarks

    History

    1. Added in 2sxc 9.40
    2. condition added in 2sxc 12.05
    3. option to just use a ToolbarBuilder as first parameter or toolbar parameter added in v13 - this will skip all other parameters
    | Improve this Doc View Source

    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.
    Usually a Dynamic Entity Objects or a Entity Objects

    If the first parameter is a IToolbarBuilder then all other parameters will be ignored.

    System.String noParamOrder

    see Convention: Named Parameters

    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 new or add buttons. This allows you to create a button for a new "Category" and another button for a new "BlogPost" etc.

    System.Object condition

    Condition will make that no toolbar is created, if it's 0, false or "false"

    System.Object prefill

    Allows a new dialog to receive values as a prefill. For example to already specify a date, title, category, etc.
    It's a dynamic object, see also the JS documentation on the prefill.

    System.Object settings

    Toolbar settings controlling hover etc.
    See Toolbar Settings

    System.Object toolbar

    Full manual toolbar configuration. Setting this will cause actions to be ignored.
    See In-Page Edit-Item Toolbars and Buttons

    If the the toolbar is a IToolbarBuilder then other parameters except for the target will be ignored.

    Returns
    Type Description
    IHybridHtmlString

    If the user is an editor, it returns HTML UL tag containing all the toolbar configuration.

    Remarks

    History

    1. Added in 2sxc 8.04
    2. condition added in 2sxc 12.05
    3. option to just use a ToolbarBuilder as first parameter or toolbar parameter added in v13 - this will skip all other parameters
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX