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
.
[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
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
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
ICanBeEntityThe content-item for which the new context should be. This item usually has a field which has Inner Content (Content Within Other Content)
noParamOrder
NoParamOrderfield
stringthe field of this content-item, which contains the inner-content-items
contentType
stringtype 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
stringRestrict the apps which can be added to this placeholder
max
intLimit 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
- Introduced in 2sxc 8.4
- Enhanced with apps and max in 10.27
- Enhanced to return
IRawHtmlString
instead ofIHybridHtmlString
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
NoParamOrderjs
bool?optional, default false. automatically true if
api
orforms
is true
Will add the basic JS APIs ($2sxc) usually for enabling WebApi calls from your JS code.
added in v10.20api
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 runforms
bool?optional, default false.
Ensures JavaScripts are loaded enabling forms to opencontext
bool?optional, default false.
If context (In-Page Editing Context (technical)) should be added, to ensure in-instance data editingautoToolbar
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
- 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, 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
objectThe optional content-item this toolbar is for. Can be null.
Usually a Dynamic Entity Objects or a Entity ObjectsIf the first parameter is a IToolbarBuilder then all other parameters will be ignored.
noParamOrder
NoParamOrderactions
stringList 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
stringContent-type of this toolbar, used when it has
new
oradd
buttons. This allows you to create a button for a new "Category" and another button for a new "BlogPost" etc.condition
objectCondition will make that no toolbar is created, if it's 0, false or "false"
prefill
objectAllows 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
objectToolbar settings controlling hover etc.
See Toolbar Settingstoolbar
objectFull manual toolbar configuration. Setting this will cause
actions
to be ignored.
See In-Page Edit-Item Toolbars and ButtonsIf the the
toolbar
is a IToolbarBuilder then other parameters except for thetarget
will be ignored.
Returns
- IRawHtmlString
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 - Enhanced to return
IRawHtmlString
instead ofIHybridHtmlString
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
objectThe content-item this toolbar is for, can be null.
Usually a Dynamic Entity Objects or a Entity ObjectsIf the first parameter is a IToolbarBuilder then all other parameters will be ignored.
noParamOrder
NoParamOrderactions
stringList 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
stringContent-type of this toolbar, used when it has
new
oradd
buttons. This allows you to create a button for a new "Category" and another button for a new "BlogPost" etc.condition
objectCondition will make that no toolbar is created, if it's 0, false or "false"
prefill
objectAllows 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
objectToolbar settings controlling hover etc.
See Toolbar Settingstoolbar
objectFull manual toolbar configuration. Setting this will cause
actions
to be ignored.
See In-Page Edit-Item Toolbars and ButtonsIf the the
toolbar
is a IToolbarBuilder then other parameters except for thetarget
will be ignored.
Returns
- IRawHtmlString
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 - Enhanced to return
IRawHtmlString
instead ofIHybridHtmlString
in 16.02