|
504 | 504 | }, |
505 | 505 |
|
506 | 506 | markdownContent: function(markdown) { |
| 507 | + console.log(aceEditor); |
507 | 508 | if (!markdown) { |
508 | | - return aceEditor.session.getvalue(); |
| 509 | + return aceEditor.getValue(); |
509 | 510 | } else { |
510 | 511 | aceEditor.session.setValue(markdown); |
511 | 512 | aceEditor.clearSelection(); |
|
518 | 519 | var html = converter.makeHtml(aceEditor.session.getValue()); |
519 | 520 | return html; |
520 | 521 | }, |
521 | | - preview: function(html) { |
522 | | - options = $.fn.codeparlMarkdown.defaults; |
523 | | - //add the preview panel |
524 | | - $container = this.parent(); |
525 | | - $preview = $('<div>').addClass('cpme-preview markdown-body overflow-auto p-2 bg-white border') |
526 | | - .appendTo($container).css({ |
527 | | - height: options.editor.editorHeight |
528 | | - }); |
529 | | - |
530 | | - |
531 | | - this.html($preview.html(disableJs(html))); |
| 522 | + preview: function(markdown,options) { |
| 523 | + if(markdown){ |
| 524 | + options = $.extend(true, {},$.fn.codeparlMarkdown.defaults, options); |
| 525 | + //add the preview panel |
| 526 | + $container = this.parent(); |
| 527 | + $preview = $('<div>').addClass('cpme-preview markdown-body overflow-auto p-2 bg-white border') |
| 528 | + .appendTo($container).css({ |
| 529 | + height: options.editorHeight, |
| 530 | + width: options.editorWidth |
| 531 | + }); |
| 532 | + if (markdown.trim().length > 0) { |
| 533 | + var html = converter.makeHtml(markdown || ''); |
| 534 | + this.html($preview.html(disableJs(html))); |
| 535 | + } |
| 536 | + } |
532 | 537 |
|
533 | 538 | }, |
534 | 539 | destroy: function() {} |
535 | 540 | }; |
536 | 541 |
|
537 | | - |
538 | 542 | //bind our plugin with jquery |
539 | 543 |
|
540 | 544 | $.fn.codeparlMarkdown = function(options) { |
|
0 commit comments