分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

Orchard Core 文档翻译 (六)HTML

发布时间:2023-09-06 02:17责任编辑:赖小花关键词:HTML

Body (OrchardCore.Html)

Theming

Shapes

将HtmlBodyPart附加到内容类型时,将呈现以下形状(Shapes)

NameDisplay TypeDefault LocationModel Type
HtmlBodyPartDetailContent:5HtmlBodyPartViewModel
HtmlBodyPartSummaryContent:10HtmlBodyPartViewModel

HtmlBodyPartViewModel

HtmlBodyPartViewModel类提供以下属性。

PropertyTypeDescription
BodystringThe content that was edited. It might contain tokens.
HtmlstringThe HTML content once all tokens have been processed
ContentItemContentItemThe content item of the part
HtmlBodyPartHtmlBodyPartThe HtmlBodyPartinstance
TypePartSettingsHtmlBodyPartSettingsThe settings of the part

HtmlBodyPart

HtmlBodyPart上提供了以下属性

NameTypeDescription
BodystringThe HTML content in the body. It can contain Liquid tags so using it directly might result in unexpected results. Prefer rendering the HtmlBodyPart shape instead
ContentThe raw content of the part 
ContentItemThe content item containing this part 

Editors 

HtmlBody Part编辑器对于每种内容类型可以是不同的。 在内容类型的HtmlBody Part 设置中,只需选择需要使用的设置即可。

有两个预定义的编辑器名称:

  • Default是默认使用的编辑器
  • Wysiwyg是提供WYSIWYG体验的编辑器

Custom Editors

自定义编辑器可能意味着用不同的体验替换预定义的编辑器,或者为用户提供可供选择的新选项。

要创建新的自定义编辑器,需要提供两个形状模板( shape templates),一个用于提供编辑器的名称(如果要覆盖现有编辑器,则为可选),以及用于呈现编辑器的实际HTML格式。

Declaration

要声明新编辑器,请创建名为HtmlBody_Option__{Name}的格式,其中{Name}是您选择的值。 这将由一个名为的文件表示 HtmlBody-{Name}.Option.cshtml.

Sample content:

@{ ???string currentEditor = Model.Editor;}<option value="Wysiwyg" selected="@(currentEditor == "Wysiwyg")">@T["Wysiwyg editor"]</option>

HTML Editor

要定义从设置中选择编辑器时要呈现的HTML,可以创建与文件Body-{Name} .Editor.cshtml 对应的名为HtmlBody_Editor __ {Name}的格式。

Sample content:

@using OrchardCore.Html.ViewModels;@model HtmlBodyPartViewModel<fieldset class="form-group"> ???<label asp-for="Body">@T["Body"]</label> ???<textarea asp-for="Body" rows="5" class="form-control"></textarea> ???<span class="hint">@T["The body of the content item."]</span></fieldset>

覆盖预定义的编辑器

您可以通过创建名为HtmlBody.Editor.cshtml的文件来覆盖默认编辑器的HTML编辑器。 Wysiwyg编辑器是使用名为HtmlBody-Wysiwyg.Editor.cshtml的文件定义的。

鸣谢

Trumbowyg

https://github.com/Alex-D/Trumbowyg
Copyright (c) 2012-2016 Alexandre Demode (Alex-D)
License: MIT

Orchard Core 文档翻译 (六)HTML

原文地址:https://www.cnblogs.com/Qbit/p/9746477.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved