mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 03:34:15 -06:00
prometheus: monaco editor: visual fixes (#41184)
* prometheus: monaco editor: visual fixes * fixed typo in comment Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> * more comments added Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
This commit is contained in:
parent
c45c246646
commit
c788e2f8e8
@ -15,24 +15,38 @@ const options: monacoTypes.editor.IStandaloneEditorConstructionOptions = {
|
||||
fixedOverflowWidgets: true,
|
||||
folding: false,
|
||||
fontSize: 14,
|
||||
lineDecorationsWidth: 8,
|
||||
lineDecorationsWidth: 8, // used as "padding-left"
|
||||
lineNumbers: 'off',
|
||||
minimap: { enabled: false },
|
||||
overviewRulerBorder: false,
|
||||
overviewRulerLanes: 0,
|
||||
padding: {
|
||||
// these numbers were picked so that visually this matches the previous version
|
||||
// of the query-editor the best
|
||||
top: 4,
|
||||
bottom: 4,
|
||||
bottom: 5,
|
||||
},
|
||||
renderLineHighlight: 'none',
|
||||
scrollbar: {
|
||||
vertical: 'hidden',
|
||||
verticalScrollbarSize: 8, // used as "padding-right"
|
||||
horizontal: 'hidden',
|
||||
horizontalScrollbarSize: 0,
|
||||
},
|
||||
scrollBeyondLastLine: false,
|
||||
suggestFontSize: 12,
|
||||
wordWrap: 'off',
|
||||
wordWrap: 'on',
|
||||
};
|
||||
|
||||
// this number was chosen by testing various values. it might be necessary
|
||||
// because of the width of the border, not sure.
|
||||
//it needs to do 2 things:
|
||||
// 1. when the editor is single-line, it should make the editor height be visually correct
|
||||
// 2. when the editor is multi-line, the editor should not be "scrollable" (meaning,
|
||||
// you do a scroll-movement in the editor, and it will scroll the content by a couple pixels
|
||||
// up & down. this we want to avoid)
|
||||
const EDITOR_HEIGHT_OFFSET = 2;
|
||||
|
||||
const PROMQL_LANG_ID = promLanguageDefinition.id;
|
||||
|
||||
// we must only run the promql-setup code once
|
||||
@ -157,7 +171,7 @@ const MonacoQueryField = (props: Props) => {
|
||||
const containerDiv = containerRef.current;
|
||||
if (containerDiv !== null) {
|
||||
const pixelHeight = editor.getContentHeight();
|
||||
containerDiv.style.height = `${pixelHeight}px`;
|
||||
containerDiv.style.height = `${pixelHeight + EDITOR_HEIGHT_OFFSET}px`;
|
||||
containerDiv.style.width = '100%';
|
||||
const pixelWidth = containerDiv.clientWidth;
|
||||
editor.layout({ width: pixelWidth, height: pixelHeight });
|
||||
|
Loading…
Reference in New Issue
Block a user