forked from refactory-id/bootstrap-markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a bug from parseContent method when used inside onPreview hook. Added an optional argument val for some reason :)
- Loading branch information
Showing
1 changed file
with
15 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -426,23 +426,17 @@ | |
return this | ||
} | ||
|
||
, parseContent: function() { | ||
var content, | ||
callbackContent = this.$options.onPreview(this) // Try to get the content from callback | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
if (typeof callbackContent == 'string') { | ||
// Set the content based by callback content | ||
content = callbackContent | ||
, parseContent: function(val) { | ||
This comment has been minimized.
Sorry, something went wrong.
lodev09
Author
Owner
|
||
var content | ||
|
||
// parse with supported markdown parser | ||
var val = val || this.$textarea.val(); | ||
if(typeof markdown == 'object') { | ||
content = markdown.toHTML(val); | ||
}else if(typeof marked == 'function') { | ||
content = marked(val); | ||
} else { | ||
// Set the content | ||
var val = this.$textarea.val(); | ||
if(typeof markdown == 'object') { | ||
content = markdown.toHTML(val); | ||
}else if(typeof marked == 'function') { | ||
content = marked(val); | ||
} else { | ||
content = val; | ||
} | ||
content = val; | ||
} | ||
|
||
return content; | ||
|
@@ -453,14 +447,17 @@ | |
container = this.$textarea, | ||
afterContainer = container.next(), | ||
replacementContainer = $('<div/>',{'class':'md-preview','data-provider':'markdown-preview'}), | ||
content | ||
content, | ||
callbackContent | ||
|
||
// Give flag that tell the editor enter preview mode | ||
this.$isPreview = true | ||
// Disable all buttons | ||
this.disableButtons('all').enableButtons('cmdPreview') | ||
|
||
content = this.parseContent() | ||
callbackContent = options.onPreview(this) // Try to get the content from callback | ||
// Set the content based from the callback content if string otherwise parse value from textarea | ||
content = typeof callbackContent == 'string' ? callbackContent : this.parseContent(); | ||
|
||
// Build preview element | ||
replacementContainer.html(content) | ||
|
This will cause an endless execution if
parseContent()
is used insideonPreview
hook.