remove app package in codemirror-module (#9322)
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>pull/9339/head
parent
f5563bfe95
commit
22fa0aa408
File diff suppressed because it is too large
Load Diff
@ -1,48 +0,0 @@ |
||||
<!-- The MIT License (MIT) |
||||
|
||||
Copyright (c) 2020 The Prometheus Authors |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
||||
--> |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>PromQL</title> |
||||
</head> |
||||
|
||||
<body> |
||||
<h3>CodeMirror Mode PromQL</h3> |
||||
<label for="completion">choose the completion mode:</label> |
||||
<select name="completion" id="completion"> |
||||
<option selected value="offline">Offline</option> |
||||
<option value="prometheus">Prometheus</option> |
||||
</select> |
||||
<br> |
||||
<label for="languageType">Language to complete</label> |
||||
<select name="languageType" id="languageType"> |
||||
<option selected value="promql">Full PromQL</option> |
||||
<option value="metricName">Metric names</option> |
||||
</select> |
||||
|
||||
<button id="apply">apply</button> |
||||
|
||||
<div id=editor></div> |
||||
</body> |
||||
</html> |
||||
@ -1,85 +0,0 @@ |
||||
// Copyright 2021 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { basicSetup } from '@codemirror/basic-setup'; |
||||
import { EditorState } from '@codemirror/state'; |
||||
import { EditorView } from '@codemirror/view'; |
||||
import { LanguageType, PromQLExtension } from '../lang-promql'; |
||||
import { customTheme, promQLHighlightMaterialTheme } from './theme'; |
||||
|
||||
const promqlExtension = new PromQLExtension(); |
||||
let editor: EditorView; |
||||
|
||||
function getLanguageType(): LanguageType { |
||||
const completionSelect = document.getElementById('languageType') as HTMLSelectElement; |
||||
const completionValue = completionSelect.options[completionSelect.selectedIndex].value; |
||||
switch (completionValue) { |
||||
case 'promql': |
||||
return LanguageType.PromQL; |
||||
case 'metricName': |
||||
return LanguageType.MetricName; |
||||
default: |
||||
return LanguageType.PromQL; |
||||
} |
||||
} |
||||
|
||||
function setCompletion() { |
||||
const completionSelect = document.getElementById('completion') as HTMLSelectElement; |
||||
const completionValue = completionSelect.options[completionSelect.selectedIndex].value; |
||||
switch (completionValue) { |
||||
case 'offline': |
||||
promqlExtension.setComplete(); |
||||
break; |
||||
case 'prometheus': |
||||
promqlExtension.setComplete({ |
||||
remote: { |
||||
url: 'https://prometheus.demo.do.prometheus.io', |
||||
}, |
||||
}); |
||||
break; |
||||
default: |
||||
promqlExtension.setComplete(); |
||||
} |
||||
} |
||||
|
||||
function createEditor() { |
||||
let doc = ''; |
||||
if (editor) { |
||||
// When the linter is changed, it required to reload completely the editor.
|
||||
// So the first thing to do, is to completely delete the previous editor and to recreate it from scratch
|
||||
// We should preserve the current text entered as well.
|
||||
doc = editor.state.sliceDoc(0, editor.state.doc.length); |
||||
editor.destroy(); |
||||
} |
||||
editor = new EditorView({ |
||||
state: EditorState.create({ |
||||
extensions: [basicSetup, promqlExtension.asExtension(getLanguageType()), promQLHighlightMaterialTheme, customTheme], |
||||
doc: doc, |
||||
}), |
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
parent: document.querySelector('#editor')!, |
||||
}); |
||||
} |
||||
|
||||
function applyConfiguration(): void { |
||||
setCompletion(); |
||||
createEditor(); |
||||
} |
||||
|
||||
createEditor(); |
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion,@typescript-eslint/ban-ts-ignore
|
||||
// @ts-ignore
|
||||
document.getElementById('apply').addEventListener('click', function () { |
||||
applyConfiguration(); |
||||
}); |
||||
@ -1,105 +0,0 @@ |
||||
// Copyright 2021 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { EditorView } from '@codemirror/view'; |
||||
import { HighlightStyle, tags } from '@codemirror/highlight'; |
||||
|
||||
// promQLHighlightMaterialTheme is based on the material theme defined here:
|
||||
// https://codemirror.net/theme/material.css
|
||||
export const promQLHighlightMaterialTheme = HighlightStyle.define([ |
||||
{ |
||||
tag: tags.deleted, |
||||
textDecoration: 'line-through', |
||||
}, |
||||
{ |
||||
tag: tags.inserted, |
||||
textDecoration: 'underline', |
||||
}, |
||||
{ |
||||
tag: tags.link, |
||||
textDecoration: 'underline', |
||||
}, |
||||
{ |
||||
tag: tags.strong, |
||||
fontWeight: 'bold', |
||||
}, |
||||
{ |
||||
tag: tags.emphasis, |
||||
fontStyle: 'italic', |
||||
}, |
||||
{ |
||||
tag: tags.invalid, |
||||
color: '#f00', |
||||
}, |
||||
{ |
||||
tag: tags.keyword, |
||||
color: '#C792EA', |
||||
}, |
||||
{ |
||||
tag: tags.operator, |
||||
color: '#89DDFF', |
||||
}, |
||||
{ |
||||
tag: tags.atom, |
||||
color: '#F78C6C', |
||||
}, |
||||
{ |
||||
tag: tags.number, |
||||
color: '#FF5370', |
||||
}, |
||||
{ |
||||
tag: tags.string, |
||||
color: '#99b867', |
||||
}, |
||||
{ |
||||
tag: [tags.escape, tags.regexp], |
||||
color: '#e40', |
||||
}, |
||||
{ |
||||
tag: tags.definition(tags.variableName), |
||||
color: '#f07178', |
||||
}, |
||||
{ |
||||
tag: tags.labelName, |
||||
color: '#f07178', |
||||
}, |
||||
{ |
||||
tag: tags.typeName, |
||||
color: '#085', |
||||
}, |
||||
{ |
||||
tag: tags.function(tags.variableName), |
||||
color: '#C792EA', |
||||
}, |
||||
{ |
||||
tag: tags.definition(tags.propertyName), |
||||
color: '#00c', |
||||
}, |
||||
{ |
||||
tag: tags.comment, |
||||
color: '#546E7A', |
||||
}, |
||||
]); |
||||
|
||||
export const customTheme = EditorView.theme({ |
||||
$completionDetail: { |
||||
marginLeft: '0.5em', |
||||
float: 'right', |
||||
color: '#9d4040', |
||||
}, |
||||
$completionMatchedText: { |
||||
color: '#83080a', |
||||
textDecoration: 'none', |
||||
fontWeight: 'bold', |
||||
}, |
||||
}); |
||||
@ -1,40 +0,0 @@ |
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires |
||||
const path = require('path'); |
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires |
||||
const HtmlWebpackPlugin = require('html-webpack-plugin'); |
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires |
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); |
||||
|
||||
module.exports = { |
||||
mode: 'development', |
||||
entry: path.join(__dirname, '/src/app/app.ts'), |
||||
output: { |
||||
filename: '[name].bundle.js', |
||||
path: path.resolve(__dirname, 'dist'), |
||||
}, |
||||
devtool: 'inline-source-map', |
||||
module: { |
||||
rules: [ |
||||
{ |
||||
test: /\.tsx?$/, |
||||
loader: 'ts-loader', |
||||
exclude: /node_modules/, |
||||
}, |
||||
], |
||||
}, |
||||
plugins: [ |
||||
new CleanWebpackPlugin({ cleanStaleWebpackAssets: false }), |
||||
new HtmlWebpackPlugin({ |
||||
hash: true, |
||||
filename: 'index.html', //relative to root of the application |
||||
path: path.resolve(__dirname, 'dist'), |
||||
template: './src/app/app.html', |
||||
}), |
||||
], |
||||
resolve: { |
||||
extensions: ['.tsx', '.ts', '.js'], |
||||
}, |
||||
devServer: { |
||||
contentBase: './dist', |
||||
}, |
||||
}; |
||||
Loading…
Reference in new issue