Fix scroll events and add minHeight and maxHeight to monaco componet

This commit is contained in:
Stanislav Romanov 2022-10-17 11:53:27 +03:00
parent 1ced61a5cd
commit c367c1e523
2 changed files with 8 additions and 2 deletions

View file

@ -60,6 +60,9 @@ export default class MonacoEditorComponent extends Component {
minimap: {
enabled: false,
},
scrollbar: {
alwaysConsumeMouseWheel: false,
},
};
if (this.args.uri) {
@ -75,12 +78,14 @@ export default class MonacoEditorComponent extends Component {
this.editor = editor.create(el, options);
const minHeight = this.args.minHeight ?? 160;
const maxHeight = this.args.maxHeight ?? 420;
// Autoresize height of element
const onDidContentSizeChangeHandler = this.editor.onDidContentSizeChange(
() => {
const contentHeight = Math.min(
Math.max(this.editor.getContentHeight(), 160),
420
Math.max(this.editor.getContentHeight(), minHeight),
maxHeight
);
el.style.height = `${contentHeight + 1}px`;

View file

@ -153,6 +153,7 @@
@value={{json-stringify item}}
@language='json'
@readOnly={{true}}
@minHeight={{0}}
class='mb-4'
/>
{{/each}}