Enable spellcheck for EasyMDE, use contenteditable mode (#19776)

Enable spellcheck for EasyMDE, use contenteditable mode.
Rewrite and refactor the ImagePaste code.
This commit is contained in:
wxiaoguang 2022-06-29 01:52:58 +08:00 committed by GitHub
parent cdd6371ad4
commit 76910f213f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 102 additions and 65 deletions

View file

@ -1,7 +1,7 @@
import $ from 'jquery';
import {createCommentEasyMDE, getAttachedEasyMDE} from './comp/EasyMDE.js';
import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js';
import {initCompImagePaste, initEasyMDEImagePaste} from './comp/ImagePaste.js';
import {initEasyMDEImagePaste} from './comp/ImagePaste.js';
import {
initRepoIssueBranchSelect, initRepoIssueCodeCommentCancel,
initRepoIssueCommentDelete,
@ -33,7 +33,8 @@ import initRepoPullRequestMergeForm from './repo-issue-pr-form.js';
const {csrfToken} = window.config;
export function initRepoCommentForm() {
if ($('.comment.form').length === 0) {
const $commentForm = $('.comment.form');
if ($commentForm.length === 0) {
return;
}
@ -67,12 +68,13 @@ export function initRepoCommentForm() {
}
(async () => {
await createCommentEasyMDE($('.comment.form textarea:not(.review-textarea)'));
initCompImagePaste($('.comment.form'));
const $textarea = $commentForm.find('textarea:not(.review-textarea)');
const easyMDE = await createCommentEasyMDE($textarea);
initEasyMDEImagePaste(easyMDE, $commentForm.find('.dropzone'));
})();
initBranchSelector();
initCompMarkupContentPreviewTab($('.comment.form'));
initCompMarkupContentPreviewTab($commentForm);
// List submits
function initListSubmits(selector, outerSelector) {
@ -352,9 +354,7 @@ async function onEditContent(event) {
easyMDE = await createCommentEasyMDE($textarea);
initCompMarkupContentPreviewTab($editContentForm);
if ($dropzone.length === 1) {
initEasyMDEImagePaste(easyMDE, $dropzone[0], $dropzone.find('.files'));
}
initEasyMDEImagePaste(easyMDE, $dropzone);
const $saveButton = $editContentZone.find('.save.button');
$textarea.on('ce-quick-submit', () => {