Orchard Core 文檔翻譯 (六)HTML

Body (OrchardCore.Html)

Theming

Shapes

將HtmlBodyPart附加到內容類型時,將呈現如下形狀(Shapes)html

Name Display Type Default Location Model Type
HtmlBodyPart Detail Content:5 HtmlBodyPartViewModel
HtmlBodyPart Summary Content:10 HtmlBodyPartViewModel

HtmlBodyPartViewModel

HtmlBodyPartViewModel類提供如下屬性。git

Property Type Description
Body string The content that was edited. It might contain tokens.
Html string The HTML content once all tokens have been processed
ContentItem ContentItem The content item of the part
HtmlBodyPart HtmlBodyPart The HtmlBodyPartinstance
TypePartSettings HtmlBodyPartSettings The settings of the part

HtmlBodyPart

HtmlBodyPart上提供瞭如下屬性github

Name Type Description
Body string The 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
Content The raw content of the part  
ContentItem The content item containing this part  

Editors 

HtmlBody Part編輯器對於每種內容類型能夠是不一樣的。 在內容類型的HtmlBody Part 設置中,只需選擇須要使用的設置便可。編輯器

有兩個預約義的編輯器名稱:ui

  • Default是默認使用的編輯器
  • Wysiwyg是提供WYSIWYG體驗的編輯器

Custom Editors

自定義編輯器可能意味着用不一樣的體驗替換預約義的編輯器,或者爲用戶提供可供選擇的新選項。this

要建立新的自定義編輯器,須要提供兩個形狀模板( shape templates),一個用於提供編輯器的名稱(若是要覆蓋現有編輯器,則爲可選),以及用於呈現編輯器的實際HTML格式。spa

Declaration

要聲明新編輯器,請建立名爲HtmlBody_Option__{Name}的格式,其中{Name}是您選擇的值。 這將由一個名爲的文件表示 HtmlBody-{Name}.Option.cshtml.翻譯

Sample content:code

 

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

 

HTML Editor

要定義從設置中選擇編輯器時要呈現的HTML,能夠建立與文件Body-{Name} .Editor.cshtml 對應的名爲HtmlBody_Editor __ {Name}的格式。orm

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

 

原文連接:http://www.javashuo.com/article/p-nqlkxtij-ez.html 

相關文章
相關標籤/搜索