mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-05-25 19:17:19 +08:00
Improve markdown textarea for indentation and lists (#31406)
Almost works like GitHub * use Tab/Shift-Tab to indent/unindent the selected lines * use Enter to insert a new line with the same indentation and prefix
This commit is contained in:
@ -10,6 +10,7 @@ import {easyMDEToolbarActions} from './EasyMDEToolbarActions.js';
|
||||
import {initTextExpander} from './TextExpander.js';
|
||||
import {showErrorToast} from '../../modules/toast.js';
|
||||
import {POST} from '../../modules/fetch.js';
|
||||
import {initTextareaMarkdown} from './EditorMarkdown.js';
|
||||
|
||||
let elementIdCounter = 0;
|
||||
|
||||
@ -84,17 +85,6 @@ class ComboMarkdownEditor {
|
||||
if (el.nodeName === 'BUTTON' && !el.getAttribute('type')) el.setAttribute('type', 'button');
|
||||
}
|
||||
|
||||
this.textarea.addEventListener('keydown', (e) => {
|
||||
if (e.shiftKey) {
|
||||
e.target._shiftDown = true;
|
||||
}
|
||||
});
|
||||
this.textarea.addEventListener('keyup', (e) => {
|
||||
if (!e.shiftKey) {
|
||||
e.target._shiftDown = false;
|
||||
}
|
||||
});
|
||||
|
||||
const monospaceButton = this.container.querySelector('.markdown-switch-monospace');
|
||||
const monospaceEnabled = localStorage?.getItem('markdown-editor-monospace') === 'true';
|
||||
const monospaceText = monospaceButton.getAttribute(monospaceEnabled ? 'data-disable-text' : 'data-enable-text');
|
||||
@ -118,6 +108,7 @@ class ComboMarkdownEditor {
|
||||
await this.switchToEasyMDE();
|
||||
});
|
||||
|
||||
initTextareaMarkdown(this.textarea);
|
||||
if (this.dropzone) {
|
||||
initTextareaPaste(this.textarea, this.dropzone);
|
||||
}
|
||||
|
Reference in New Issue
Block a user