Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update codemirror to v6 #795

Merged
merged 8 commits into from
Jul 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
774 changes: 346 additions & 428 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
"changelog": "git cliff v0.0.4..$(git describe --tags $(git rev-list --tags --max-count=1)) --output CHANGELOG.md"
},
"dependencies": {
"@codemirror/basic-setup": "^0.19.0",
"@codemirror/highlight": "^0.19.6",
"@codemirror/lang-javascript": "^0.19.3",
"@codemirror/lang-json": "^0.19.1",
"@codemirror/language": "^0.19.7",
"@codemirror/legacy-modes": "^0.19.0",
"@codemirror/search": "^0.19.4",
"@codemirror/state": "^0.19.6",
"@codemirror/stream-parser": "^0.19.2",
"@codemirror/view": "^0.19.28",
"@codemirror/basic-setup": "^0.20.0",
"@codemirror/highlight": "^0.19.8",
dw-0 marked this conversation as resolved.
Show resolved Hide resolved
"@codemirror/lang-javascript": "^0.20.0",
"@codemirror/lang-json": "^0.20.0",
"@codemirror/language": "^0.20.0",
"@codemirror/legacy-modes": "^0.20.0",
"@codemirror/search": "^0.20.0",
"@codemirror/state": "^0.20.0",
"@codemirror/view": "^0.20.4",
"@lezer/highlight": "^0.16.0",
"@sindarius/gcodeviewer": "^2.1.17",
"@types/node": "^16.11.22",
"@types/overlayscrollbars": "^1.12.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/Codemirror.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Component, Mixins, Prop, Watch } from 'vue-property-decorator'
import BaseMixin from '../mixins/base'
import { basicSetup, EditorState } from '@codemirror/basic-setup'
import { mainsailTheme } from '@/plugins/codemirrorTheme'
import { StreamLanguage } from '@codemirror/stream-parser'
import { StreamLanguage } from '@codemirror/language'
import { klipper_config } from '@/plugins/StreamParserKlipperConfig'
import { gcode } from '@/plugins/StreamParserGcode'
import { EditorView, keymap } from '@codemirror/view'
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/StreamParserGcode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StringStream } from '@codemirror/stream-parser'
import { StringStream } from '@codemirror/language'

export const gcode = {
token: function (stream: StringStream, state: StreamParserGcodeState, zeroPos = 0): string | null {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/StreamParserJinja2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
import {StringStream} from "@codemirror/stream-parser";
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",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/StreamParserKlipperConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StringStream } from '@codemirror/stream-parser'
import { StringStream } from '@codemirror/language'
import { gcode } from '@/plugins/StreamParserGcode'

export const klipper_config = {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/StreamParserYaml.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StringStream } from '@codemirror/stream-parser'
import { StringStream } from '@codemirror/language'

const cons = ['true', 'false', 'on', 'off', 'yes', 'no']
const keywordRegex = new RegExp('\\b((' + cons.join(')|(') + '))$', 'i')
Expand Down
13 changes: 9 additions & 4 deletions src/plugins/codemirrorTheme.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { EditorView } from '@codemirror/view'
import { Extension } from '@codemirror/state'
import { HighlightStyle, tags as t } from '@codemirror/highlight'
import { tags as t } from '@lezer/highlight'
import { HighlightStyle, syntaxHighlighting } from '@codemirror/language'

const ui = {
background: '#1e1e1e',
foreground: '#d4d4d4',
}

export const mainsailEditor = EditorView.theme(
const mainsailEditor = EditorView.theme(
{
'&': {
color: '#d4d4d4',
Expand Down Expand Up @@ -40,7 +41,7 @@ export const mainsailEditor = EditorView.theme(
{ dark: true }
)

export const mainsailHighlightStyle = HighlightStyle.define([
const mainsailHighlightStyle = HighlightStyle.define([
{ tag: t.number, color: '#b5cea8' },
{ tag: [t.meta], color: '#d4d4d4' },
{ tag: [t.comment], color: '#6a9955' },
Expand All @@ -51,7 +52,11 @@ export const mainsailHighlightStyle = HighlightStyle.define([
{ 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, mainsailHighlightStyle]
export const mainsailTheme: Extension = [mainsailEditor, syntaxHighlighting(mainsailHighlightStyle)]