mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: auto-resize editor by default
This commit is contained in:
1 parent
cd3f8af392
commit
34cd4d62e9
5 files changed
+9
-17
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.24.21",
|
||||
"version": "2.24.22",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -423,7 +423,7 @@ export class Handler extends HandlerCommon {
|
||||
query: ctx.query,
|
||||
path: ctx.path,
|
||||
params: ctx.params,
|
||||
referer: ctx.request.headers.referer || '/',
|
||||
referer: ctx.request.headers.referer,
|
||||
json: (ctx.request.headers.accept || '').includes('application/json'),
|
||||
};
|
||||
this.response = {
|
||||
@@ -520,7 +520,7 @@ export class Handler extends HandlerCommon {
|
||||
text: global.Hydro.lib[key].text,
|
||||
}));
|
||||
if (!this.noCheckPermView) this.checkPerm(PERM.PERM_VIEW);
|
||||
if (this.request.method === 'post' && this.request.headers.referer !== '/') {
|
||||
if (this.request.method === 'post' && this.request.headers.referer) {
|
||||
const host = new URL(this.request.headers.referer).host;
|
||||
if (host !== this.request.host) throw new CsrfTokenError(host);
|
||||
}
|
||||
|
||||
@@ -50,9 +50,7 @@ function onClickDummyBox(ev) {
|
||||
const $evTarget = $(ev.currentTarget);
|
||||
|
||||
if (CommentBox.get($evTarget)) {
|
||||
CommentBox
|
||||
.get($evTarget)
|
||||
.focus();
|
||||
CommentBox.get($evTarget).focus();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,9 +123,7 @@ async function onCommentClickEdit(mode, ev) {
|
||||
const $evTarget = $(ev.currentTarget);
|
||||
|
||||
if (CommentBox.get($evTarget)) {
|
||||
CommentBox
|
||||
.get($evTarget)
|
||||
.focus();
|
||||
CommentBox.get($evTarget).focus();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,9 +170,7 @@ async function onCommentClickDelete(type, ev) {
|
||||
<p>${i18n(message)}</p>
|
||||
</div>`,
|
||||
}).open();
|
||||
if (action !== 'yes') {
|
||||
return;
|
||||
}
|
||||
if (action !== 'yes') return;
|
||||
|
||||
const $evTarget = $(ev.currentTarget);
|
||||
const form = JSON.parse($evTarget.attr('data-form'));
|
||||
|
||||
@@ -40,8 +40,7 @@ export default class Editor extends DOMAttachedObject {
|
||||
const hasFocus = $dom.is(':focus') || $dom.hasClass('autofocus');
|
||||
const origin = $dom.get(0);
|
||||
const ele = document.createElement('div');
|
||||
$(ele).width('100%');
|
||||
$(ele).addClass('textbox');
|
||||
$(ele).width('100%').addClass('textbox');
|
||||
$dom.hide();
|
||||
origin.parentElement.appendChild(ele);
|
||||
const value = $dom.val();
|
||||
@@ -49,7 +48,7 @@ export default class Editor extends DOMAttachedObject {
|
||||
onChange, language = 'markdown',
|
||||
theme = UserContext.monacoTheme || 'vs-light',
|
||||
model = `file://model-${Math.random().toString(16)}`,
|
||||
autoResize = $dom.hasClass('auto-resize'),
|
||||
autoResize = true,
|
||||
} = this.options;
|
||||
this.model = typeof model === 'string' ? monaco.editor.createModel(value, language, monaco.Uri.parse(model)) : model;
|
||||
const cfg = {
|
||||
@@ -63,7 +62,6 @@ export default class Editor extends DOMAttachedObject {
|
||||
if (autoResize) {
|
||||
cfg.scrollbar = {
|
||||
vertical: 'hidden',
|
||||
alwaysConsumeMouseWheel: false,
|
||||
handleMouseWheel: false,
|
||||
};
|
||||
cfg.scrollBeyondLastLine = false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.7.7",
|
||||
"version": "4.7.8",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
Reference in new issue
Block a user