ui: auto move cursor to end

This commit is contained in:
undefined committed 2021-05-05 19:08:58 +08:00
1 parent a03a77bd52
commit ecf04d3b7d
3 files changed
+5 -6

No files matched your search

@@ -118,7 +118,7 @@ async function onCommentClickReplyReply(ev) {
$evTarget $evTarget
.closest('.dczcomments__item') .closest('.dczcomments__item')
.find('[name="dczcomments__op-reply-comment"]').eq(0) .find('[name="dczcomments__op-reply-comment"]').eq(0)
.trigger('click', { initialText: `@${username}: ` }); .trigger('click', { initialText: `@${username.trim()}: ` });
} }
async function onCommentClickEdit(mode, ev) { async function onCommentClickEdit(mode, ev) {
@@ -78,7 +78,6 @@ export default class Editor extends DOMAttachedObject {
label: 'Use light theme', label: 'Use light theme',
run: () => monaco.editor.setTheme('vs-light'), run: () => monaco.editor.setTheme('vs-light'),
}); });
let prevHeight = 0; let prevHeight = 0;
const updateEditorHeight = () => { const updateEditorHeight = () => {
const editorElement = this.editor.getDomNode(); const editorElement = this.editor.getDomNode();
@@ -92,12 +91,10 @@ export default class Editor extends DOMAttachedObject {
this.editor.layout(); this.editor.layout();
} }
}; };
this.editor.onDidChangeModelDecorations(() => { this.editor.onDidChangeModelDecorations(() => {
updateEditorHeight(); // typing updateEditorHeight(); // typing
requestAnimationFrame(updateEditorHeight); // folding requestAnimationFrame(updateEditorHeight); // folding
}); });
this._subscription = this.editor.onDidChangeModelContent(() => { this._subscription = this.editor.onDidChangeModelContent(() => {
const val = this.editor.getValue(); const val = this.editor.getValue();
$dom.val(val); $dom.val(val);
@@ -105,7 +102,7 @@ export default class Editor extends DOMAttachedObject {
if (onChange) onChange(val); if (onChange) onChange(val);
}); });
this.isValid = true; this.isValid = true;
if (hasFocus) this.editor.focus(); if (hasFocus) this.focus();
} }
async initVditor() { async initVditor() {
@@ -150,6 +147,8 @@ export default class Editor extends DOMAttachedObject {
focus() { focus() {
this.ensureValid(); this.ensureValid();
this.editor.focus(); this.editor.focus();
const range = this.model.getFullModelRange();
this.editor.setPosition({ lineNumber: range.endLineNumber, column: range.endColumn });
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/ui-default", "name": "@hydrooj/ui-default",
"version": "4.6.33", "version": "4.6.34",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "hydro.js", "main": "hydro.js",