ui: auto move cursor to end

pull/134/head
undefined 3 years ago
parent a03a77bd52
commit ecf04d3b7d

@ -118,7 +118,7 @@ async function onCommentClickReplyReply(ev) {
$evTarget
.closest('.dczcomments__item')
.find('[name="dczcomments__op-reply-comment"]').eq(0)
.trigger('click', { initialText: `@${username}: ` });
.trigger('click', { initialText: `@${username.trim()}: ` });
}
async function onCommentClickEdit(mode, ev) {

@ -78,7 +78,6 @@ export default class Editor extends DOMAttachedObject {
label: 'Use light theme',
run: () => monaco.editor.setTheme('vs-light'),
});
let prevHeight = 0;
const updateEditorHeight = () => {
const editorElement = this.editor.getDomNode();
@ -92,12 +91,10 @@ export default class Editor extends DOMAttachedObject {
this.editor.layout();
}
};
this.editor.onDidChangeModelDecorations(() => {
updateEditorHeight(); // typing
requestAnimationFrame(updateEditorHeight); // folding
});
this._subscription = this.editor.onDidChangeModelContent(() => {
const val = this.editor.getValue();
$dom.val(val);
@ -105,7 +102,7 @@ export default class Editor extends DOMAttachedObject {
if (onChange) onChange(val);
});
this.isValid = true;
if (hasFocus) this.editor.focus();
if (hasFocus) this.focus();
}
async initVditor() {
@ -150,6 +147,8 @@ export default class Editor extends DOMAttachedObject {
focus() {
this.ensureValid();
this.editor.focus();
const range = this.model.getFullModelRange();
this.editor.setPosition({ lineNumber: range.endLineNumber, column: range.endColumn });
}
}

@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.6.33",
"version": "4.6.34",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",

Loading…
Cancel
Save