Browse Source

Implemented content fragment vc for Page/Create

pull/13499/head
malik masis 4 years ago
parent
commit
1ffed21c80
  1. 14
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/create.js
  2. 18
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml

14
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/create.js

@ -1,6 +1,6 @@
$(function () { $(function () {
var l = abp.localization.getResource("CmsKit"); var l = abp.localization.getResource("CmsKit");
var $createForm = $('#form-page-create'); var $createForm = $('#form-page-create');
var $title = $('#ViewModel_Title'); var $title = $('#ViewModel_Title');
var $slug = $('#ViewModel_Slug'); var $slug = $('#ViewModel_Slug');
@ -173,7 +173,17 @@ $(function () {
$('.tab-item').on('click', function () { $('.tab-item').on('click', function () {
if ($(this).attr("aria-label") == 'Preview' && editor.isMarkdownMode()) { if ($(this).attr("aria-label") == 'Preview' && editor.isMarkdownMode()) {
editor.setMarkdown(editor.getMarkdown(), true);
let content = editor.getMarkdown();
localStorage.setItem('content', content);
volo.cmsKit.contents.content.parseAsHtml(content).then(function (data) {
editor.setHTML(data);
});
}
else if ($(this).attr("aria-label") == 'Write'){
var retrievedObject = localStorage.getItem('content');
editor.setMarkdown(retrievedObject);
} }
}); });

18
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml

@ -2,17 +2,12 @@
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap @addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
@using Volo.CmsKit.Contents @using Volo.CmsKit.Contents
@using System.Dynamic @using System.Dynamic
@using Volo.CmsKit.Public.Web.Renderers
@using Volo.Abp.Data @using Volo.Abp.Data
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs; @using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs;
@using Volo.Abp.AspNetCore.Mvc.UI.Widgets; @using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
@inject IMarkdownToHtmlRenderer MarkdownRenderer
@model Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages.IndexModel @model Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages.IndexModel
@section styles{ @section styles{
<abp-style src="/Pages/Public/CmsKit/Pages/index.css" /> <abp-style src="/Pages/Public/CmsKit/Pages/index.css" />
@ -30,18 +25,7 @@
<abp-card> <abp-card>
<abp-card-body> <abp-card-body>
@foreach (ContentFragment contentFragment in Model.PageDto.ContentFragments) @await Component.InvokeAsync("ContentFragment", new { pageDto = Model.PageDto })
{
if (contentFragment.Type == ContentConsts.Markdown)
{
@Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty<string>("Content")))
}
else if (contentFragment.Type == ContentConsts.Widget)
{
@await Component.InvokeAsync(contentFragment.GetProperty<string>("Type"), contentFragment.ExtraProperties.ConvertToDynamicObject())
}
}
</abp-card-body> </abp-card-body>
</abp-card> </abp-card>

Loading…
Cancel
Save