Skip to content

Commit

Permalink
Added support for HTML Excerpt. Fixes #1150
Browse files Browse the repository at this point in the history
  • Loading branch information
tidyui committed May 25, 2020
1 parent 3cedd2e commit 7b6b955
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 15 deletions.
9 changes: 7 additions & 2 deletions core/Piranha.Manager/Areas/Manager/Pages/PageEdit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,13 @@
</div>
</div>
<div class="unsortable" v-if="useExcerpt">
<div class="block text-block ingress">
<div class="block-body" :class="{ empty: isExcerptEmpty }">
<div v-if="useHtmlExcerpt" class="block text-block ingress" :class="{ empty: isExcerptEmpty }">
<div id="excerpt-toolbar" class="component-toolbar"></div>
<div id="excerpt-body" class="block-body html-block" spellcheck="false" contenteditable="true" v-html="excerpt" v-on:blur="onExcerptBlur">
</div>
</div>
<div v-else class="block text-block ingress ingress-text" :class="{ empty: isExcerptEmpty }">
<div class="block-body">
<p spellcheck="false" contenteditable="true" v-html="excerpt" v-on:blur="onExcerptBlur"></p>
</div>
</div>
Expand Down
9 changes: 7 additions & 2 deletions core/Piranha.Manager/Areas/Manager/Pages/PostEdit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,13 @@
</div>
</div>
<div class="unsortable" v-if="useExcerpt">
<div class="block text-block ingress">
<div class="block-body" :class="{ empty: isExcerptEmpty }">
<div v-if="useHtmlExcerpt" class="block text-block ingress" :class="{ empty: isExcerptEmpty }">
<div id="excerpt-toolbar" class="component-toolbar"></div>
<div id="excerpt-body" class="block-body html-block" spellcheck="false" contenteditable="true" v-html="excerpt" v-on:blur="onExcerptBlur">
</div>
</div>
<div v-else class="block text-block ingress ingress-text" :class="{ empty: isExcerptEmpty }">
<div class="block-body">
<p spellcheck="false" contenteditable="true" v-html="excerpt" v-on:blur="onExcerptBlur"></p>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions core/Piranha.Manager/Models/PageEditModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,11 @@ public class PageEditModel : Content.ContentEditModel
/// post type. The default value is true.
/// </summary>
public bool UseExcerpt { get; set; } = true;

/// <summary>
/// Gets/sets if excerpt should in HTML-format. The
/// default value is false.
/// </summary>
public bool UseHtmlExcerpt { get; set; } = false;
}
}
6 changes: 6 additions & 0 deletions core/Piranha.Manager/Models/PostEditModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,11 @@ public class PostEditModel : Content.ContentEditModel
/// post type. The default value is true.
/// </summary>
public bool UseExcerpt { get; set; } = true;

/// <summary>
/// Gets/sets if excerpt should in HTML-format. The
/// default value is false.
/// </summary>
public bool UseHtmlExcerpt { get; set; } = false;
}
}
1 change: 1 addition & 0 deletions core/Piranha.Manager/Services/PageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ private PageEditModel Transform(DynamicPage page, bool isDraft)
UseBlocks = type.UseBlocks,
UsePrimaryImage = type.UsePrimaryImage,
UseExcerpt = type.UseExcerpt,
UseHtmlExcerpt = config.HtmlExcerpt,
SelectedRoute = route == null ? null : new RouteModel
{
Title = route.Title,
Expand Down
1 change: 1 addition & 0 deletions core/Piranha.Manager/Services/PostService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ private PostEditModel Transform(DynamicPost post, bool isDraft)
UseBlocks = type.UseBlocks,
UsePrimaryImage = type.UsePrimaryImage,
UseExcerpt = type.UseExcerpt,
UseHtmlExcerpt = config.HtmlExcerpt,
SelectedRoute = route == null ? null : new RouteModel
{
Title = route.Title,
Expand Down
2 changes: 1 addition & 1 deletion core/Piranha.Manager/assets/dist/css/full.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/Piranha.Manager/assets/dist/css/slim.min.css

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions core/Piranha.Manager/assets/dist/js/piranha.pageedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ piranha.pageedit = new Vue({
useBlocks: true,
usePrimaryImage: true,
useExcerpt: true,
useHtmlExcerpt: true,
permissions: [],
primaryImage: {
id: null,
Expand Down Expand Up @@ -108,6 +109,7 @@ piranha.pageedit = new Vue({
this.useBlocks = model.useBlocks;
this.usePrimaryImage = model.usePrimaryImage;
this.useExcerpt = model.useExcerpt;
this.useHtmlExcerpt = model.useHtmlExcerpt;
this.isCopy = model.isCopy;
this.selectedRoute = model.selectedRoute;
this.routes = model.routes;
Expand Down Expand Up @@ -401,6 +403,7 @@ piranha.pageedit = new Vue({
})[0].addEventListener("sortupdate", function (e) {
piranha.pageedit.moveBlock(e.detail.origin.index, e.detail.destination.index);
});
piranha.editor.addInline('excerpt-body', 'excerpt-toolbar');
}
else {
sortable("#content-blocks", "disable");
Expand Down
Loading

0 comments on commit 7b6b955

Please sign in to comment.