Skip to content

Commit

Permalink
Use upstream format bookkeeping to ensure we only render markdown whe…
Browse files Browse the repository at this point in the history
…n markdown is provided (#2161)
  • Loading branch information
cbeer authored and mejackreed committed Apr 18, 2019
1 parent c1bf913 commit 06bb56c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/assets/javascripts/spotlight/block_mixins/formable.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@
/* Simple to start. Add conditions later */
if (this.hasTextBlock()) {
data.text = this.getTextBlockHTML();
data.format = 'html';
if (data.text.length > 0 && this.options.convertToMarkdown) {
data.text = stToMarkdown(data.text, this.type);
data.format = 'markdown';
}
}

return data;
},

loadData: function(data){
if (this.hasTextBlock()) {
$(this.getTextBlock()).html(SirTrevor.toHTML(data.text, this.type));
if (this.options.convertFromMarkdown && data.format !== "html") {
this.setTextBlockHTML(SirTrevor.toHTML(data.text, this.type));
} else {
this.setTextBlockHTML(data.text);
}
this.loadFormDataByKey(data);
this.afterLoadData(data);
Expand Down

0 comments on commit 06bb56c

Please sign in to comment.