|
1 | 1 | import {htmlEscape} from 'escape-goat';
|
2 | 2 | import attachTribute from './tribute.js';
|
3 |
| -import {createCommentSimpleMDE} from './comp/CommentSimpleMDE.js'; |
| 3 | +import {createCommentEasyMDE, getAttachedEasyMDE} from './comp/CommentEasyMDE.js'; |
4 | 4 | import {initCompImagePaste} from './comp/ImagePaste.js';
|
5 | 5 | import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js';
|
6 | 6 |
|
@@ -213,8 +213,8 @@ export function initRepoIssueStatusButton() {
|
213 | 213 | // Change status
|
214 | 214 | const $statusButton = $('#status-button');
|
215 | 215 | $('#comment-form textarea').on('keyup', function () {
|
216 |
| - const $simplemde = $(this).data('simplemde'); |
217 |
| - const value = ($simplemde && $simplemde.value()) ? $simplemde.value() : $(this).val(); |
| 216 | + const easyMDE = getAttachedEasyMDE(this); |
| 217 | + const value = easyMDE?.value() || $(this).val(); |
218 | 218 | $statusButton.text($statusButton.data(value.length === 0 ? 'status' : 'status-and-comment'));
|
219 | 219 | });
|
220 | 220 | $statusButton.on('click', () => {
|
@@ -445,22 +445,19 @@ export function initRepoPullRequestReview() {
|
445 | 445 | const form = $(this).closest('.comment-code-cloud').find('.comment-form');
|
446 | 446 | form.removeClass('hide');
|
447 | 447 | const $textarea = form.find('textarea');
|
448 |
| - let $simplemde; |
449 |
| - if ($textarea.data('simplemde')) { |
450 |
| - $simplemde = $textarea.data('simplemde'); |
451 |
| - } else { |
| 448 | + let easyMDE = getAttachedEasyMDE($textarea); |
| 449 | + if (!easyMDE) { |
452 | 450 | attachTribute($textarea.get(), {mentions: true, emoji: true});
|
453 |
| - $simplemde = createCommentSimpleMDE($textarea); |
454 |
| - $textarea.data('simplemde', $simplemde); |
| 451 | + easyMDE = createCommentEasyMDE($textarea); |
455 | 452 | }
|
456 | 453 | $textarea.focus();
|
457 |
| - $simplemde.codemirror.focus(); |
| 454 | + easyMDE.codemirror.focus(); |
458 | 455 | assignMenuAttributes(form.find('.menu'));
|
459 | 456 | });
|
460 | 457 |
|
461 | 458 | const $reviewBox = $('.review-box');
|
462 | 459 | if ($reviewBox.length === 1) {
|
463 |
| - createCommentSimpleMDE($reviewBox.find('textarea')); |
| 460 | + createCommentEasyMDE($reviewBox.find('textarea')); |
464 | 461 | initCompImagePaste($reviewBox);
|
465 | 462 | }
|
466 | 463 |
|
@@ -519,9 +516,9 @@ export function initRepoPullRequestReview() {
|
519 | 516 | td.find("input[name='path']").val(path);
|
520 | 517 | const $textarea = commentCloud.find('textarea');
|
521 | 518 | attachTribute($textarea.get(), {mentions: true, emoji: true});
|
522 |
| - const $simplemde = createCommentSimpleMDE($textarea); |
| 519 | + const easyMDE = createCommentEasyMDE($textarea); |
523 | 520 | $textarea.focus();
|
524 |
| - $simplemde.codemirror.focus(); |
| 521 | + easyMDE.codemirror.focus(); |
525 | 522 | }
|
526 | 523 | });
|
527 | 524 | }
|
|
0 commit comments