Use monaco for the git hook editor (#13552)
Migrate git hook editor to monaco, replacing CodeMirror. Had to do a few refactors to make the monaco instantiation generic enough to be of use. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
a2efcb6acc
commit
374ff60465
7 changed files with 74 additions and 62 deletions
|
@ -23,7 +23,7 @@ import createDropzone from './features/dropzone.js';
|
|||
import initTableSort from './features/tablesort.js';
|
||||
import ActivityTopAuthors from './components/ActivityTopAuthors.vue';
|
||||
import {initNotificationsTable, initNotificationCount} from './features/notification.js';
|
||||
import {createCodeEditor} from './features/codeeditor.js';
|
||||
import {createCodeEditor, createMonaco} from './features/codeeditor.js';
|
||||
import {svg, svgs} from './svg.js';
|
||||
import {stripTags} from './utils.js';
|
||||
|
||||
|
@ -1732,15 +1732,10 @@ function initUserSettings() {
|
|||
}
|
||||
}
|
||||
|
||||
function initGithook() {
|
||||
if ($('.edit.githook').length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
CodeMirror.autoLoadMode(CodeMirror.fromTextArea($('#content')[0], {
|
||||
lineNumbers: true,
|
||||
mode: 'shell'
|
||||
}), 'shell');
|
||||
async function initGithook() {
|
||||
if ($('.edit.githook').length === 0) return;
|
||||
const filename = document.querySelector('.hook-filename').textContent;
|
||||
await createMonaco($('#content')[0], filename, {language: 'shell'});
|
||||
}
|
||||
|
||||
function initWebhook() {
|
||||
|
@ -2517,7 +2512,6 @@ $(document).ready(async () => {
|
|||
initEditForm();
|
||||
initEditor();
|
||||
initOrganization();
|
||||
initGithook();
|
||||
initWebhook();
|
||||
initAdmin();
|
||||
initCodeView();
|
||||
|
@ -2575,6 +2569,7 @@ $(document).ready(async () => {
|
|||
initServiceWorker(),
|
||||
initNotificationCount(),
|
||||
renderMarkdownContent(),
|
||||
initGithook(),
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue