|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
import tinycolor from 'tinycolor2';
|
|
|
|
import {basename, extname, isObject, isDarkTheme} from '../utils.js';
|
|
|
|
import {basename, extname, isObject, isDarkTheme} from '../utils.js';
|
|
|
|
import {onInputDebounce} from '../utils/dom.js';
|
|
|
|
import {onInputDebounce} from '../utils/dom.js';
|
|
|
|
|
|
|
|
|
|
|
@ -69,33 +70,34 @@ export async function createMonaco(textarea, filename, editorOpts) {
|
|
|
|
textarea.parentNode.append(container);
|
|
|
|
textarea.parentNode.append(container);
|
|
|
|
|
|
|
|
|
|
|
|
// https://github.com/microsoft/monaco-editor/issues/2427
|
|
|
|
// https://github.com/microsoft/monaco-editor/issues/2427
|
|
|
|
|
|
|
|
// also, monaco can only parse 6-digit hex colors, so we convert the colors to that format
|
|
|
|
const styles = window.getComputedStyle(document.documentElement);
|
|
|
|
const styles = window.getComputedStyle(document.documentElement);
|
|
|
|
const getProp = (name) => styles.getPropertyValue(name).trim();
|
|
|
|
const getColor = (name) => tinycolor(styles.getPropertyValue(name).trim()).toString('hex6');
|
|
|
|
|
|
|
|
|
|
|
|
monaco.editor.defineTheme('gitea', {
|
|
|
|
monaco.editor.defineTheme('gitea', {
|
|
|
|
base: isDarkTheme() ? 'vs-dark' : 'vs',
|
|
|
|
base: isDarkTheme() ? 'vs-dark' : 'vs',
|
|
|
|
inherit: true,
|
|
|
|
inherit: true,
|
|
|
|
rules: [
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
background: getProp('--color-code-bg'),
|
|
|
|
background: getColor('--color-code-bg'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
],
|
|
|
|
colors: {
|
|
|
|
colors: {
|
|
|
|
'editor.background': getProp('--color-code-bg'),
|
|
|
|
'editor.background': getColor('--color-code-bg'),
|
|
|
|
'editor.foreground': getProp('--color-text'),
|
|
|
|
'editor.foreground': getColor('--color-text'),
|
|
|
|
'editor.inactiveSelectionBackground': getProp('--color-primary-light-4'),
|
|
|
|
'editor.inactiveSelectionBackground': getColor('--color-primary-light-4'),
|
|
|
|
'editor.lineHighlightBackground': getProp('--color-editor-line-highlight'),
|
|
|
|
'editor.lineHighlightBackground': getColor('--color-editor-line-highlight'),
|
|
|
|
'editor.selectionBackground': getProp('--color-primary-light-3'),
|
|
|
|
'editor.selectionBackground': getColor('--color-primary-light-3'),
|
|
|
|
'editor.selectionForeground': getProp('--color-primary-light-3'),
|
|
|
|
'editor.selectionForeground': getColor('--color-primary-light-3'),
|
|
|
|
'editorLineNumber.background': getProp('--color-code-bg'),
|
|
|
|
'editorLineNumber.background': getColor('--color-code-bg'),
|
|
|
|
'editorLineNumber.foreground': getProp('--color-secondary-dark-6'),
|
|
|
|
'editorLineNumber.foreground': getColor('--color-secondary-dark-6'),
|
|
|
|
'editorWidget.background': getProp('--color-body'),
|
|
|
|
'editorWidget.background': getColor('--color-body'),
|
|
|
|
'editorWidget.border': getProp('--color-secondary'),
|
|
|
|
'editorWidget.border': getColor('--color-secondary'),
|
|
|
|
'input.background': getProp('--color-input-background'),
|
|
|
|
'input.background': getColor('--color-input-background'),
|
|
|
|
'input.border': getProp('--color-input-border'),
|
|
|
|
'input.border': getColor('--color-input-border'),
|
|
|
|
'input.foreground': getProp('--color-input-text'),
|
|
|
|
'input.foreground': getColor('--color-input-text'),
|
|
|
|
'scrollbar.shadow': getProp('--color-shadow'),
|
|
|
|
'scrollbar.shadow': getColor('--color-shadow'),
|
|
|
|
'progressBar.background': getProp('--color-primary'),
|
|
|
|
'progressBar.background': getColor('--color-primary'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|