refactor: improve syntax highlighting and change theme in editor (#1200)

Co-authored-by: truckershitch <truckershitch@hambone.e4ward.com>
Co-authored-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
authored and GitHub committed 2023-05-18 16:40:57 +02:00
1 parent 140d796f51
commit 080a713f4c
9 files changed
+341 -465

No files matched your search

+1
View File
@@ -14,6 +14,7 @@ temp
package-lock.json
*.local
.env
.vscode
cypress/screenshots/
cypress/videos/
+42
View File
@@ -21,6 +21,7 @@
"@sindarius/gcodeviewer": "^3.2.2",
"@types/node": "^18.0.0",
"@types/overlayscrollbars": "^1.12.1",
"@uiw/codemirror-theme-vscode": "^4.19.11",
"axios": "^0.27.0",
"codemirror": "^6.0.1",
"core-js": "^3.16.0",
@@ -3117,6 +3118,29 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@uiw/codemirror-theme-vscode": {
"version": "4.19.11",
"resolved": "https://registry.npmjs.org/@uiw/codemirror-theme-vscode/-/codemirror-theme-vscode-4.19.11.tgz",
"integrity": "sha512-/SAei4iiIizEOvJ1rvIUc8y8HZLkIgzEWiC9UOZTAOKVcxIE7SLt1nTG3XRmPrceSltPgfTb0dLrsXoHQIPYKw==",
"dependencies": {
"@uiw/codemirror-themes": "4.19.11"
}
},
"node_modules/@uiw/codemirror-themes": {
"version": "4.19.11",
"resolved": "https://registry.npmjs.org/@uiw/codemirror-themes/-/codemirror-themes-4.19.11.tgz",
"integrity": "sha512-4bh0vfkqeVJ7L2aGimKXqQtaoSEe/1xZb9nkGn35V5daHXkxRhb+BRFMOSrMsjGm74hM+dvYi5iH8HXVsvjJrQ==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0"
},
"peerDependencies": {
"@codemirror/language": ">=6.0.0",
"@codemirror/state": ">=6.0.0",
"@codemirror/view": ">=6.0.0"
}
},
"node_modules/@vue/babel-helper-vue-jsx-merge-props": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@vue/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-1.4.0.tgz",
@@ -12392,6 +12416,24 @@
"eslint-visitor-keys": "^3.3.0"
}
},
"@uiw/codemirror-theme-vscode": {
"version": "4.19.11",
"resolved": "https://registry.npmjs.org/@uiw/codemirror-theme-vscode/-/codemirror-theme-vscode-4.19.11.tgz",
"integrity": "sha512-/SAei4iiIizEOvJ1rvIUc8y8HZLkIgzEWiC9UOZTAOKVcxIE7SLt1nTG3XRmPrceSltPgfTb0dLrsXoHQIPYKw==",
"requires": {
"@uiw/codemirror-themes": "4.19.11"
}
},
"@uiw/codemirror-themes": {
"version": "4.19.11",
"resolved": "https://registry.npmjs.org/@uiw/codemirror-themes/-/codemirror-themes-4.19.11.tgz",
"integrity": "sha512-4bh0vfkqeVJ7L2aGimKXqQtaoSEe/1xZb9nkGn35V5daHXkxRhb+BRFMOSrMsjGm74hM+dvYi5iH8HXVsvjJrQ==",
"requires": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0"
}
},
"@vue/babel-helper-vue-jsx-merge-props": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@vue/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-1.4.0.tgz",
+1
View File
@@ -36,6 +36,7 @@
"@sindarius/gcodeviewer": "^3.2.2",
"@types/node": "^18.0.0",
"@types/overlayscrollbars": "^1.12.1",
"@uiw/codemirror-theme-vscode": "^4.19.11",
"axios": "^0.27.0",
"codemirror": "^6.0.1",
"core-js": "^3.16.0",
+5 -4
View File
@@ -12,7 +12,7 @@ import BaseMixin from '../mixins/base'
import { basicSetup } from 'codemirror'
import { EditorView, keymap } from '@codemirror/view'
import { EditorState } from '@codemirror/state'
import { mainsailTheme } from '@/plugins/codemirrorTheme'
import { vscodeDark } from '@uiw/codemirror-theme-vscode'
import { StreamLanguage } from '@codemirror/language'
import { klipper_config } from '@/plugins/StreamParserKlipperConfig'
import { gcode } from '@/plugins/StreamParserGcode'
@@ -82,9 +82,10 @@ export default class Codemirror extends Mixins(BaseMixin) {
get cmExtensions() {
const extensions = [
EditorView.theme({}, { dark: true }),
basicSetup,
mainsailTheme,
indentUnit.of(' '.repeat(this.getTabSize())),
vscodeDark,
indentUnit.of(' '.repeat(this.tabSize)),
keymap.of([indentWithTab]),
EditorView.updateListener.of((update) => {
this.content = update.state?.doc.toString()
@@ -106,7 +107,7 @@ export default class Codemirror extends Mixins(BaseMixin) {
if (isVisible) this.cminstance?.focus()
}
getTabSize() {
get tabSize() {
return this.$store.state.gui.editor.tabSize || 2
}
}
+13 -5
View File
@@ -9,11 +9,19 @@ export const gcode = {
/* Klipper macro attributes */
if (stream.pos > zeroPos && state.klipperMacro) {
stream.eatSpace()
if (stream.match(/^(".+"|true|false)/i)) {
if (stream.match(/^{/)) {
return 'tag'
}
// else if (stream.match(/^'|"/)) {
else if (stream.match(/^"[^{]+"/) || stream.match(/^'[^{]+'/)) {
return 'string'
} else if (stream.match(/^\d+/)) return 'number'
else if (stream.match(/^[A-Za-z\d_]+/)) return 'propertyName'
else if (zeroPos === 0 && stream.match(/^{[^%]+}/)) return 'variable'
} else if (stream.match(/^[-+]?[0-9]*\.?[0-9]+/)) {
return 'number'
} else if (stream.match(/^[A-Za-z\d_]+/)) {
return 'propertyName'
} else if (zeroPos === 0 && stream.match(/^{[^%]+}/)) {
return 'variable'
}
}
/* comments */
@@ -29,7 +37,7 @@ export const gcode = {
return 'namespace'
}
if (stream.string.substr(zeroPos).toLowerCase().startsWith('m117')) {
if (stream.string.substring(zeroPos).toLowerCase().startsWith('m117')) {
stream.skipToEnd()
return 'string'
}
-144
View File
@@ -1,144 +0,0 @@
/*
import {StringStream} from "@codemirror/language";
let keywords = ["and", "as", "block", "endblock", "by", "cycle", "debug", "else", "elif",
"extends", "filter", "endfilter", "firstof", "for",
"endfor", "if", "endif", "ifchanged", "endifchanged",
"ifequal", "endifequal", "ifnotequal",
"endifnotequal", "in", "include", "load", "not", "now", "or",
"parsed", "regroup", "reversed", "spaceless",
"endspaceless", "ssi", "templatetag", "openblock",
"closeblock", "openvariable", "closevariable",
"openbrace", "closebrace", "opencomment",
"closecomment", "widthratio", "url", "with", "endwith",
"get_current_language", "trans", "endtrans", "noop", "blocktrans",
"endblocktrans", "get_available_languages",
"get_current_language_bidi", "plural"];
const operator = /^[+\-*&%=<>!?|~^]/;
const sign = /^[:[({]/;
let atom = ["true", "false"];
const number = /^(\d[+\-*!/])?\d+(\.\d+)?/;
keywords = new RegExp("((" + keywords.join(")|(") + "))\\b");
atom = new RegExp("((" + atom.join(")|(") + "))\\b");
export const jinja2 = {
token: function(stream: StringStream, state: StreamParserJinja2State): string {
let ch: string | void = stream.peek();
//Comment
if (state.incomment) {
if(!stream.skipTo("#}")) {
stream.skipToEnd();
} else {
stream.eatWhile(/[#}]/);
state.incomment = false;
}
return "comment";
//Tag
} else if (state.intag) {
//After operator
if(state.operator) {
state.operator = false;
if(stream.match(atom)) {
return "atom";
}
if(stream.match(number)) {
return "number";
}
}
//After sign
if(state.sign) {
state.sign = false;
if(stream.match(atom)) {
return "atom";
}
if(stream.match(number)) {
return "number";
}
}
if(state.instring) {
if(ch == state.instring) {
state.instring = false;
}
stream.next();
return "string";
} else if(ch == "'" || ch == '"') {
state.instring = ch;
stream.next();
return "string";
} else if(stream.match(state.intag + "}") || stream.eat("-") && stream.match(state.intag + "}")) {
state.intag = false;
return "tag";
} else if(stream.match(operator)) {
state.operator = true;
return "operator";
} else if(stream.match(sign)) {
state.sign = true;
} else {
if(stream.eat(" ") || stream.sol()) {
if(stream.match(keywords)) {
return "keyword";
}
if(stream.match(atom)) {
return "atom";
}
if(stream.match(number)) {
return "number";
}
if(stream.sol()) {
stream.next();
}
} else {
stream.next();
}
}
return "variable";
} else if (stream.eat("{")) {
if (stream.eat("#")) {
state.incomment = true;
if(!stream.skipTo("#}")) {
stream.skipToEnd();
} else {
stream.eatWhile(/[#}]/);
state.incomment = false;
}
return "comment";
//Open tag
// eslint-disable-next-line no-cond-assign
} else if (ch = stream.eat(/[{%]/)) {
//Cache close tag
state.intag = ch;
if(ch == "{") {
state.intag = "}";
}
stream.eat("-");
return "tag";
}
}
stream.next();
},
startState: function(): StreamParserJinja2State {
return {
incomment: false,
intag: false,
operator: false,
sign: false,
instring: false
};
},
languageData: {
blockCommentStart: "{#",
blockCommentEnd: "#}"
}
}
export interface StreamParserJinja2State {
incomment: boolean,
intag: string | boolean,
operator: boolean,
sign: boolean,
instring: boolean | string,
}
*/
+279 -41
View File
@@ -3,6 +3,212 @@ import { gcode } from '@/plugins/StreamParserGcode'
export const klipper_config: StreamParser<any> = {
token: function (stream: StringStream, state: StreamParserKlipperConfigState): string | null {
/* see https://tedboy.github.io/jinja2/off_doc.templates.html */
const operators = [
'\\+',
'-',
'\\/\\/',
'\\/',
'%',
'\\*\\*',
'\\*',
'\\(',
'\\)',
'==',
'!=',
'>=',
'>',
'<=',
'<',
'=',
'\\|',
'~',
',',
]
const reOperator = new RegExp('^' + operators.join('|'))
const keywords = [
'elif',
'else',
'endif',
'if',
'endfor',
'for',
'loop\\.index',
'loop\\.revindex',
'loop\\.first',
'loop\\.last',
'loop\\.length',
'loop\\.cycle',
'loop\\.depth',
'and',
'or',
'not',
'in',
'is',
'endmacro',
'macro',
'endcall',
'call',
'endfilter',
'filter',
'endset',
'set',
'extends',
'block',
'endblock',
'include',
'import',
'do',
]
const filters = [
'abs',
'attr',
'batch',
'capitalize',
'center',
'default',
'dictsort',
'escape',
'filesizeformat',
'first',
'float',
'forceescape',
'format',
'groupby',
'indent',
'int',
'join',
'last',
'length',
'list',
'lower',
'map',
'max',
'min',
'pprint',
'random',
'reject',
'rejectattr',
'replace',
'reverse',
'round',
'tojson',
'safe',
'select',
'selectattr',
'slice',
'sort',
'string',
'striptags',
'sum',
'title',
'trim',
'truncate',
'unique',
'upper',
'urlencode',
'urlize',
'wordcount',
'wordwrap',
'xmlattr',
]
const tests = [
'callable',
'defined',
'divisibleby',
'equalto',
'escaped',
'even',
'iterable',
'lower',
'mapping',
'none',
'number',
'odd',
'sameas',
'sequence',
'string',
'undefined',
'upper',
]
const globalFns = ['range', 'lipsum', 'dict', 'cycler', 'joiner']
const cyclerMethods = ['\\.reset\\(\\)', '\\.next\\(\\)']
const reKeyword = new RegExp('^' + keywords.join('\\s+|') + '|' + cyclerMethods.join('|') + '\\s+')
const reUpdateOps = new RegExp(
'^' + filters.join('|') + '|' + tests.join('|') + '|' + globalFns.join('|') + '\\s+'
)
function jinja2Element(stream: StringStream): string {
const pctMatch: any = stream.match(/^%}/)
const braceMatch: any = stream.match(/^}/)
function notJinja(): boolean {
return state.klipperMacroJinjaBraceStack.length === 0 && state.klipperMacroJinjaPctStack.length === 0
}
if (pctMatch || braceMatch) {
if (pctMatch) {
state.klipperMacroJinjaPctStack.pop()
if (notJinja()) {
state.klipperMacroJinja = false
}
} else {
// brace match
state.klipperMacroJinjaBraceStack.pop()
if (notJinja()) {
state.klipperMacroJinja = false
}
}
stream.eatSpace()
state.gcodeZeroPos = stream.pos
return 'tag'
}
// https://www.metaltoad.com/blog/regex-quoted-string-escapable-quotes
if (stream.match(/^((?<![\\])['"])((?:.(?!(?<![\\])\1))*.?)\1/)) {
state.klipperMacroJinjaHighlightNext = true
return 'string'
}
if (stream.eol() && stream.match(/^"/)) {
state.klipperMacroJinjaHighlightNext = false
return 'string'
}
if (state.klipperMacroJinjaHighlightNext) {
if (stream.match(reKeyword)) {
state.klipperMacroJinjaHighlightNext = false
return 'keyword'
}
}
if (state.klipperMacroJinjaHighlightNext) {
if (stream.match(reUpdateOps)) {
// check character after "updateOp" element -- might not be a "("
if (['(', '}', ',', '|', ' '].includes(stream.peek() ?? '')) {
state.klipperMacroJinjaHighlightNext = false
return 'updateOperator'
}
}
}
if (stream.match(reOperator)) {
state.klipperMacroJinjaHighlightNext = true
return 'number'
}
if (stream.match(/^true\s|false\s/i)) {
state.klipperMacroJinjaHighlightNext = false
return 'atom'
}
if (stream.match(/^[-+]?[0-9]*\.?[0-9]+/)) {
state.klipperMacroJinjaHighlightNext = false
return 'number'
}
if (stream.eatSpace()) {
state.klipperMacroJinjaHighlightNext = true
return 'propertyName'
}
stream.next()
state.klipperMacroJinjaHighlightNext = false
return 'propertyName'
}
const ch = stream.peek()
/* comments */
if (
@@ -50,57 +256,57 @@ export const klipper_config: StreamParser<any> = {
stream.eatSpace()
state.gcodeZeroPos = stream.pos
}
if (state.klipperMacroJinja) {
if (
(state.klipperMacroJinjaPercent && stream.match(/^%}/)) ||
(!state.klipperMacroJinjaPercent && stream.match(/^}/))
) {
state.klipperMacroJinja = false
state.klipperMacroJinjaPercent = false
stream.eatSpace()
state.gcodeZeroPos = stream.pos
return null
}
stream.next()
return 'string'
}
if (stream.match(/^\s*{[%{]?/)) {
state.klipperMacroJinjaPercent = stream.string.includes('{%')
if (stream.match(/^\s*{[%#]?/)) {
state.klipperMacroJinja = true
return null
if (stream.string.includes('{%')) {
state.klipperMacroJinjaPctStack.push('{%')
} else {
state.klipperMacroJinjaBraceStack.push('{')
}
return 'tag'
}
if (state.klipperMacroJinja) {
return jinja2Element(stream)
}
return gcode.token(stream, state, state.gcodeZeroPos ?? 0)
}
} else {
// stream.indentation > 0
state.was = true
if (state.gcode) {
if (stream.sol()) {
stream.eatSpace()
state.gcodeZeroPos = stream.pos
}
if (state.klipperMacroJinja) {
if (
(state.klipperMacroJinjaPercent && stream.match(/^%}/)) ||
(!state.klipperMacroJinjaPercent && stream.match(/^}/))
) {
state.klipperMacroJinja = false
state.klipperMacroJinjaPercent = false
stream.eatSpace()
state.gcodeZeroPos = stream.pos
return null
}
stream.next()
return 'string'
}
if (stream.match(/^\s*{[%{]?/)) {
state.klipperMacroJinjaPercent = stream.string.includes('{%')
if (stream.match(/^\s*{[%#]?/)) {
state.klipperMacroJinja = true
return null
if (stream.string.includes('{%')) {
state.klipperMacroJinjaPctStack.push('{%')
} else {
state.klipperMacroJinjaBraceStack.push('{')
}
return 'tag'
}
if (state.klipperMacroJinja) {
return jinja2Element(stream)
}
return gcode.token(stream, state, state.gcodeZeroPos ?? stream.pos)
} else if (state.variable) {
if (stream.sol()) {
stream.eatSpace()
}
if (stream.match(/^\s*{[%#]?/)) {
state.klipperMacroJinja = true
if (stream.string.includes('{%')) {
state.klipperMacroJinjaPctStack.push('{%')
} else {
state.klipperMacroJinjaBraceStack.push('{')
}
return 'tag'
}
if (state.klipperMacroJinja) {
return jinja2Element(stream)
}
} else if (state.pair) {
stream.eatSpace()
if (ch !== ',') {
@@ -118,12 +324,15 @@ export const klipper_config: StreamParser<any> = {
if (state.was && stream.indentation() === 0) {
state.pair = false
state.gcode = false
state.variable = false
state.was = false
}
if (!state.pair && !state.gcode && stream.sol()) {
if (!state.pair && !state.gcode && !state.variable && stream.sol()) {
if (stream.match(/^(?:[A-Za-z]*_?gcode|enable):/)) {
state.gcode = true
} else if (stream.match(/^variable_[a-zA-Z]+:/)) {
state.variable = true
} else {
stream.match(/^.+?:\s*/)
state.pair = !stream.eol()
@@ -132,6 +341,30 @@ export const klipper_config: StreamParser<any> = {
return 'atom'
}
if (state.variable) {
if (stream.sol() || stream.eol()) {
state.variable = false
return null
}
if (stream.match(/^\s*{[%#]?/)) {
state.klipperMacroJinja = true
if (stream.string.includes('{%')) {
state.klipperMacroJinjaPctStack.push('{%')
} else {
state.klipperMacroJinjaBraceStack.push('{')
}
return 'tag'
} else {
// no Jinja in variable
state.pair = true
// state.variable = false
}
if (state.klipperMacroJinja) {
stream.eatSpace()
return jinja2Element(stream)
}
}
if (state.pair) {
if (ch === ':') {
stream.next()
@@ -143,7 +376,6 @@ export const klipper_config: StreamParser<any> = {
state.pair = false
return null
}
if (stream.match(/^(-?\d*\.?(?:\d+)?(,|$|\s))+/)) {
state.pair = false
return 'number'
@@ -163,10 +395,13 @@ export const klipper_config: StreamParser<any> = {
pair: false,
was: false,
gcode: false,
variable: false,
klipperMacro: false,
gcodeZeroPos: null,
klipperMacroJinja: false,
klipperMacroJinjaPercent: false,
klipperMacroJinjaHighlightNext: false,
klipperMacroJinjaBraceStack: [],
klipperMacroJinjaPctStack: [],
}
},
languageData: {
@@ -179,8 +414,11 @@ interface StreamParserKlipperConfigState {
pair: boolean
was: boolean
gcode: boolean
variable: boolean
gcodeZeroPos: number | null
klipperMacro: boolean
klipperMacroJinja: boolean
klipperMacroJinjaPercent: boolean
klipperMacroJinjaHighlightNext: boolean // Highlight next element if no space follows curent keyword
klipperMacroJinjaBraceStack: string[] // Should these two stacks be combined for overhead / aesthetics?
klipperMacroJinjaPctStack: string[]
}
-140
View File
@@ -1,140 +0,0 @@
import { StringStream } from '@codemirror/language'
const cons = ['true', 'false', 'on', 'off', 'yes', 'no']
const keywordRegex = new RegExp('\\b((' + cons.join(')|(') + '))$', 'i')
export const yaml = {
token: function (stream: StringStream, state: StreamParserYamlState): string | null {
const ch = stream.peek()
const esc = state.escaped
state.escaped = false
/* comments */
if (ch == '#' && (stream.pos == 0 || /\s/.test(stream.string.charAt(stream.pos - 1)))) {
stream.skipToEnd()
return 'comment'
}
if (stream.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/)) return 'string'
if (state.literal && stream.indentation() > state.keyCol) {
stream.skipToEnd()
return 'string'
} else if (state.literal) {
state.literal = false
}
if (stream.sol()) {
state.keyCol = 0
state.pair = false
state.pairStart = false
/* document start */
if (stream.match('---')) {
return 'def'
}
/* document end */
if (stream.match('...')) {
return 'def'
}
/* array list item */
if (stream.match(/^\s*-\s+/)) {
return 'meta'
}
}
if (stream.match(/^\[[a-zA-Z]\s/)) {
window.console.log('keys', stream)
return 'number'
}
/* inline pairs/lists */
if (stream.match(/^(\{|\}|\[|\])/)) {
if (ch == '{') state.inlinePairs++
else if (ch == '}') state.inlinePairs--
else if (ch == '[') state.inlineList++
else state.inlineList--
return 'meta'
}
/* list separator */
if (state.inlineList > 0 && !esc && ch == ',') {
stream.next()
return 'meta'
}
/* pairs separator */
if (state.inlinePairs > 0 && !esc && ch == ',') {
state.keyCol = 0
state.pair = false
state.pairStart = false
stream.next()
return 'meta'
}
/* start of value of a pair */
if (state.pairStart) {
/* block literals */
if (stream.match(/^\s*(\||>)\s*/)) {
state.literal = true
return 'meta'
}
/* references */
if (stream.match(/^\s*(&|\*)[a-z0-9._-]+\b/i)) {
return 'variable'
}
/* numbers */
if (state.inlinePairs == 0 && stream.match(/^\s*-?[0-9.,]+\s?$/)) {
return 'number'
}
if (state.inlinePairs > 0 && stream.match(/^\s*-?[0-9.,]+\s?(?=(,|}))/)) {
return 'number'
}
/* keywords */
if (stream.match(keywordRegex)) {
return 'keyword'
}
}
/* pairs (associative arrays) -> key */
if (
!state.pair &&
stream.match(/^\s*(?:[,[\]{}&*!|>'"%@`][^\s'":]|[^,[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)
) {
state.pair = true
state.keyCol = stream.indentation()
return 'atom'
}
if (state.pair && stream.match(/^:\s*/)) {
state.pairStart = true
return 'meta'
}
/* nothing found, continue */
state.pairStart = false
state.escaped = ch == '\\'
stream.next()
return null
},
startState: function (): StreamParserYamlState {
return {
pair: false,
pairStart: false,
keyCol: 0,
inlinePairs: 0,
inlineList: 0,
literal: false,
escaped: false,
}
},
languageData: {
commentTokens: { line: '#' },
},
}
interface StreamParserYamlState {
pair: boolean
pairStart: boolean
keyCol: number
inlinePairs: number
inlineList: number
literal: boolean
escaped: boolean
}
-131
View File
@@ -1,131 +0,0 @@
import { EditorView } from '@codemirror/view'
import { Extension } from '@codemirror/state'
import { tags as t } from '@lezer/highlight'
import { HighlightStyle, syntaxHighlighting } from '@codemirror/language'
const ui = {
background: '#1e1e1e',
foreground: '#d4d4d4',
}
const mainsailEditor = EditorView.theme(
{
'&': {
color: '#d4d4d4',
backgroundColor: ui.background,
},
'.cm-activeLine.cm-line': {
caretColor: '#d4d4d4 !important',
},
'.cm-gutters': {
backgroundColor: ui.background,
color: '#858585',
border: 'none',
},
'.cm-activeLine': {
background: 'rgba(43,47,61,0.5)',
},
'.cm-activeLineGutter': {
color: '#c6c6c6',
backgroundColor: 'rgba(33, 36, 49, 0.5)',
},
'.cm-selectionMatch': {
backgroundColor: '#add6ff26',
},
'.cm-button': {
'font-family': 'Roboto,sans-serif',
'font-weight': '500',
'font-size': '.675rem',
'letter-spacing': '0.0892857143em',
'vertical-align': 'middle',
padding: '0.3em 1em',
'border-radius': '4px',
'border-width': '0',
color: 'var(--color-primary)',
'background-color': 'var(--v-secondary-darken2)',
'background-image': 'none!important',
'text-transform': 'uppercase',
'text-indent': '0.0892857143em',
'text-aling': 'left',
},
'.cm-textfield:focus': {
'border-color': 'var(--color-primary)!important',
},
'.cm-textfield:focus-visible': {
'border-color': 'var(--color-primary)!important',
},
'.cm-textfield::placeholder': {
'text-transform': 'uppercase',
},
'.cm-panel.cm-search label': {
'font-weight': '500',
'font-family': 'Roboto,sans-serif',
'letter-spacing': '0.0892857143em',
'text-transform': 'uppercase',
'font-size': '12px',
'white-space': 'pre',
color: 'var(--v-primary-base)',
},
'.cm-panel.cm-search [name=close]': {
'font-family': 'Roboto,sans-serif',
'text-transform': 'uppercase',
'font-size': '200%',
'white-space': 'pre',
color: 'var(--color-primary)',
'padding-right': '5px',
'padding-top': '5px',
},
'.cm-button:hover': {
'background-color': 'var(--v-secondary-lighten1)',
'background-image': 'none!important',
'transition-duration': '0.5s',
'transition-timing-function': 'cubic-bezier(1.2,0,.2,1)',
},
'.cm-textfield': {
'font-family': 'Roboto,sans-serif',
'vertical-align': 'middle',
'font-size': '.675rem',
border: '1px solid silver',
backgroundColor: ui.background,
padding: '.3em .1em',
'padding-left': '0.6em',
'border-radius': '0.2em',
},
'.cm-panels': {
'background-color': 'var(--v-toolbar-base)',
},
},
{ dark: true }
)
const mainsailHighlightStyle = HighlightStyle.define([
{ tag: t.number, color: '#b5cea8' },
{ tag: [t.meta], color: '#d4d4d4' },
{ tag: [t.comment], color: '#6a9955' },
{ tag: t.atom, color: '#9cdcfe' },
{ tag: t.string, color: '#4ec9b0' },
{ tag: t.namespace, color: '#569cd6', fontWeight: 'bold' },
{ tag: t.className, color: '#c586c0' },
{ tag: t.name, color: '#e40', fontWeight: 'bold' },
{ tag: t.propertyName, color: '#e56735' },
])
const fn0 = mainsailHighlightStyle.style
// noinspection JSConstantReassignment
// @ts-ignore
mainsailHighlightStyle.style = (tags) => fn0(tags || [])
/// Extension to enable the Mox theme (both the editor theme and
/// the highlight style).
export const mainsailTheme: Extension = [mainsailEditor, syntaxHighlighting(mainsailHighlightStyle)]