Browse Source

CmsKit - Fix short description generation from markdown

pull/8191/head
enisn 6 years ago
parent
commit
344dcdf71a
  1. 11
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js

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

@ -174,17 +174,16 @@
}); });
var shorDescriptionEdited = false; var shorDescriptionEdited = false;
$pageContentInput.on('change', function () {
function reflectContentChanges(htmlContent) {
if (shorDescriptionEdited) { if (shorDescriptionEdited) {
return; return;
} }
var htmlValue = $pageContentInput.val(); var plainValue = jQuery('<div>').html(htmlContent).text().replace(/\n/g, ' ').substring(0, 120);
var plainValue = jQuery('<div>').html(htmlValue).text().replace(/\n/g, ' ').substring(0, 120);
$shortDescription.val(plainValue); $shortDescription.val(plainValue);
}); }
$shortDescription.on('change', function () { $shortDescription.on('change', function () {
shorDescriptionEdited = true; shorDescriptionEdited = true;
@ -243,6 +242,8 @@
change: function (_val) { change: function (_val) {
$editorInput.val(editor.getMarkdown()); $editorInput.val(editor.getMarkdown());
$editorInput.trigger("change"); $editorInput.trigger("change");
debugger;
reflectContentChanges(editor.getHtml());
} }
} }
}).data(editorDataKey); }).data(editorDataKey);

Loading…
Cancel
Save