Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #81 from yamgent/fix-panel-heading
Browse files Browse the repository at this point in the history
Panel: Change header markdown rendering to non-inline
  • Loading branch information
yamgent authored Jul 20, 2018
2 parents 5afeb20 + 43f969f commit 6b87950
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/Panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,43 @@
return this.cardType === 'bg-light' || this.cardType === 'bg-white' || this.cardType === 'bg-warning';
},
headerContent () {
if (this.isSeamless) {
return this.caretHtml + ' ' + this.renderedHeader;
}
return this.renderedHeader;
},
altContent () {
return this.alt && md.render(this.alt) || this.renderedHeader;
},
renderedHeader () {
return md.renderInline(this.header);
let htmlRenderedHeader = md.render(this.header).trim();
if (this.isSeamless) {
// insert the caret to the header content
let caretAdded = false;
// if the header content is wrapped by a <p> or any <h1>, <h2>, ...
// then it must be inserted inside these HTML tags, otherwise the
// header content will not be in the same line as caret
const tags = [
['<p>', '</p>'],
['<h1>', '</h1>'],
['<h2>', '</h2>'],
['<h3>', '</h3>'],
['<h4>', '</h4>'],
['<h5>', '</h5>'],
['<h6>', '</h6>']];
tags.forEach(header => {
if (!caretAdded && htmlRenderedHeader.startsWith(header[0])) {
htmlRenderedHeader = jQuery(htmlRenderedHeader).unwrap().prepend(this.caretHtml + ' ')
.wrap(header[0] + header[1]).parent().html();
caretAdded = true;
}
});
if (!caretAdded) {
htmlRenderedHeader = this.caretHtml + ' ' + htmlRenderedHeader;
}
}
return htmlRenderedHeader;
},
hasSrc () {
return this.src && this.src.length > 0;
Expand Down

0 comments on commit 6b87950

Please sign in to comment.