Interface IEditService
Service on Kit.Edit with status and commands to configure the in-page editing system.
[PublicApi]
public interface IEditService : IHasLog
- Inherited Members
Remarks
You will never create this yourself, as get this automatically in Razor or WebAPIs on an object called Edit.
History
- First version created ca. v2 - originally as
ToSic.Sxc.Web.IInPageEditEditingHelper - Moved to
ToSic.Sxc.Services.IEditServicein 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
namestringthe attribute name, used for ...=
valueobjectthe 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
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
targetICanBeEntityThe content-item for which the new context should be. This item usually has a field which has Inner Content (Content Within Other Content)
noParamOrderNoParamOrderfieldstringthe field of this content-item, which contains the inner-content-items
contentTypestringtype name used for 'new' items in a toolbar - usually for inner-content and list-contexts
newGuidGuid?the guid of a new item - use null for auto-generate
appsstringRestrict the apps which can be added to this placeholder
maxintLimit 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
IRawHtmlStringinstead ofIHybridHtmlStringin 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
noParamOrderNoParamOrderjsbool?optional, default false. automatically true if
apiorformsis true
Will add the basic JS APIs ($2sxc) usually for enabling WebApi calls from your JS code.
added in v10.20apibool?optional, default false. automatically true, if
formsis true
If JS etc. should be included to enable editing API - ensures JavaScripts are loaded enabling commands to runformsbool?optional, default false.
Ensures JavaScripts are loaded enabling forms to opencontextbool?optional, default false.
If context (In-Page Editing Context (technical)) should be added, to ensure in-instance data editingautoToolbarbool?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)stylesbool?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
targetobjectThe 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.
noParamOrderNoParamOrderactionsstringList 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.
contentTypestringContent-type of this toolbar, used when it has
neworaddbuttons. This allows you to create a button for a new "Category" and another button for a new "BlogPost" etc.conditionobjectCondition will make that no toolbar is created, if it's 0, false or "false"
prefillobjectAllows a
newdialog 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.settingsobjectToolbar settings controlling hover etc.
See Toolbar SettingstoolbarobjectFull manual toolbar configuration. Setting this will cause
actionsto be ignored.
See In-Page Edit-Item Toolbars and ButtonsIf the the
toolbaris a IToolbarBuilder then other parameters except for thetargetwill 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
conditionadded in 2sxc 12.05- option to just use a ToolbarBuilder as first parameter or
toolbarparameter added in v13 - this will skip all other parameters - Enhanced to return
IRawHtmlStringinstead ofIHybridHtmlStringin 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
targetobjectThe 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.
noParamOrderNoParamOrderactionsstringList 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.
contentTypestringContent-type of this toolbar, used when it has
neworaddbuttons. This allows you to create a button for a new "Category" and another button for a new "BlogPost" etc.conditionobjectCondition will make that no toolbar is created, if it's 0, false or "false"
prefillobjectAllows a
newdialog 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.settingsobjectToolbar settings controlling hover etc.
See Toolbar SettingstoolbarobjectFull manual toolbar configuration. Setting this will cause
actionsto be ignored.
See In-Page Edit-Item Toolbars and ButtonsIf the the
toolbaris a IToolbarBuilder then other parameters except for thetargetwill 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
conditionadded in 2sxc 12.05- option to just use a ToolbarBuilder as first parameter or
toolbarparameter added in v13 - this will skip all other parameters - Enhanced to return
IRawHtmlStringinstead ofIHybridHtmlStringin 16.02