Table of Contents

Interface IEditService

Namespace
ToSic.Sxc.Services
Assembly
ToSic.Sxc.dll

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.

[PublicApi]
public interface IEditService : IHasLog
Inherited Members

Remarks

History

  • First version created ca. v2 - originally as ToSic.Sxc.Web.IInPageEditEditingHelper
  • Moved to ToSic.Sxc.Services.IEditService in v13.05

Properties

Enabled

If editing is enabled or not

bool Enabled { get; set; }

Property Value

bool

True if enabled, false if not.

Methods

Attribute(string, object)

Generate an HTML attribute by converting the value to JSON

  • but only in edit mode
IRawHtmlString Attribute(string name, object value)

Parameters

name string

the attribute name, used for ...=

value object

the attribute value, used for ="..."

Returns

IRawHtmlString

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
IRawHtmlString Attribute(string name, string value)

Parameters

name string

the attribute name, used for ...=

value string

the attribute value, used for ="..."

Returns

IRawHtmlString

A string but as HtmlString, so it can be used with @Attribute(...)

ContextAttributes(ICanBeEntity, NoParamOrder, string, string, Guid?, string, int)

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)

IRawHtmlString ContextAttributes(ICanBeEntity target, NoParamOrder noParamOrder = default, string field = null, string contentType = null, Guid? newGuid = null, string apps = null, int max = 100)

Parameters

target ICanBeEntity

The content-item for which the new context should be. This item usually has a field which has Inner Content (Content Within Other Content)

noParamOrder NoParamOrder

see Convention: Named Parameters

field string

the field of this content-item, which contains the inner-content-items

contentType string

type name used for 'new' items in a toolbar - usually for inner-content and list-contexts

newGuid Guid?

the guid of a new item - use null for auto-generate

apps string

Restrict the apps which can be added to this placeholder

max int

Limit the amount of content-blocks that can be added to this placeholder

Returns

IRawHtmlString

An ToSic.Razor.Markup.IRawHtmlString 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
  3. Enhanced to return IRawHtmlString instead of IHybridHtmlString in 16.02

Enable(NoParamOrder, bool?, bool?, bool?, bool?, bool?, bool?)

Ensure that the UI will load the correct assets to enable editing. See Method in C# Razor (Deprecated)

string Enable(NoParamOrder noParamOrder = default, bool? js = null, bool? api = null, bool? forms = null, bool? context = null, bool? autoToolbar = null, bool? styles = null)

Parameters

noParamOrder NoParamOrder

see Convention: Named Parameters

js bool?

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

api bool?

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

forms bool?

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

context bool?

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

autoToolbar bool?

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)

styles bool?

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

Returns

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

TagToolbar(object, NoParamOrder, string, string, object, object, object, object)

Generate a toolbar attribute inside an html-tag
See also @HowTo.Razor.Edit.Toolbar

IRawHtmlString TagToolbar(object target = null, NoParamOrder noParamOrder = default, string actions = null, string contentType = null, object condition = null, object prefill = null, object settings = null, object toolbar = null)

Parameters

target object

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.

noParamOrder NoParamOrder

see Convention: Named Parameters

actions string

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.

contentType string

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.

condition object

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

prefill object

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.

settings object

Toolbar settings controlling hover etc.
See Toolbar Settings

toolbar object

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

IRawHtmlString

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
  4. Enhanced to return IRawHtmlString instead of IHybridHtmlString in 16.02

Toolbar(object, NoParamOrder, 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

IRawHtmlString Toolbar(object target = null, NoParamOrder noParamOrder = default, string actions = null, string contentType = null, object condition = null, object prefill = null, object settings = null, object toolbar = null)

Parameters

target object

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.

noParamOrder NoParamOrder

see Convention: Named Parameters

actions string

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.

contentType string

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.

condition object

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

prefill object

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.

settings object

Toolbar settings controlling hover etc.
See Toolbar Settings

toolbar object

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

IRawHtmlString

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
  4. Enhanced to return IRawHtmlString instead of IHybridHtmlString in 16.02