|
1 | 1 | (function($) {
|
2 | 2 | var editor;
|
| 3 | + var allEditors = []; |
3 | 4 | $.fn.setAsEditor = function(selector) {
|
4 | 5 | selector = selector || '.BodyBox,.js-bodybox';
|
5 | 6 |
|
|
564 | 565 |
|
565 | 566 | // forceSync = true, need to clear form after async requests
|
566 | 567 | $currentEditableTextarea.closest('form').on('complete', function (frm, btn) {
|
567 |
| - editor.codemirror.setValue(''); |
| 568 | + var mainEditor = allEditors[0]; |
| 569 | + mainEditor.codemirror.setValue(''); |
568 | 570 | });
|
569 | 571 |
|
570 | 572 | editor.codemirror.on('change', function (cm, event) {
|
|
615 | 617 | }
|
616 | 618 | }
|
617 | 619 | });
|
| 620 | + // We have only one main editor at a page which should used for quote/replyto |
| 621 | + // FIX: https://github.com/topcoder-platform/forums/issues/540 |
| 622 | + if(allEditors.length == 0) { |
| 623 | + allEditors.push(editor); |
| 624 | + } |
618 | 625 | }
|
619 | 626 | }; //editorInit
|
620 | 627 |
|
|
646 | 653 | $(postForm).find('#Form_CategoryID').val(categoryID);
|
647 | 654 | }
|
648 | 655 | var uploads = element.attr("uploads");
|
649 |
| - editor.enableUploadImages(uploads === "1"); |
| 656 | + var mainEditor = allEditors[0]; |
| 657 | + mainEditor.enableUploadImages(uploads === "1"); |
650 | 658 | });
|
651 | 659 |
|
652 | 660 | // Preview mode
|
|
664 | 672 | });
|
665 | 673 |
|
666 | 674 | // Comment with quotes
|
667 |
| - $(document).on('ApplyQuoteText',function(ev, quoteText) { |
668 |
| - var text = editor.value(); |
669 |
| - editor.value(quoteText + '\n' + text + '\n'); |
| 675 | + $(document).on('ApplyQuoteText',function(ev, quoteText, ed) { |
| 676 | + var mainEditor = allEditors[0]; |
| 677 | + var text = mainEditor.value(); |
| 678 | + mainEditor.value(quoteText + '\n' + text + '\n'); |
670 | 679 | });
|
671 | 680 | }(jQuery));
|
0 commit comments