From 5406b6afa7581b541302eb734758d2749cfe6273 Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Thu, 7 Sep 2023 17:12:17 +0200 Subject: [PATCH] Upgrade to latest Codemirror 6 --- apps/example/package.json | 29 +- apps/example/src/Editor.svelte | 4 +- .../src/projections/ChangeProjection.svelte | 5 +- .../src/projections/ReplaceProjection.svelte | 9 +- .../src/projections/TrimProjection.svelte | 7 +- .../src/projections/changeProjection.ts | 2 +- apps/generate/package.json | 2 +- apps/generate/templates.ts | 5 +- apps/jupyter/package.json | 56 +- apps/jupyter/src/editor.ts | 13 +- .../src/projections/DisplayProjection.svelte | 5 +- .../src/projections/JoinProjection.svelte | 13 +- .../projections/LoadSheetProjection.svelte | 7 +- .../projections/StoreSheetProjection.svelte | 9 +- .../src/projections/TakeProjection.svelte | 9 +- apps/parser-playground/package.json | 8 +- apps/python-dsl/package.json | 30 +- apps/python-dsl/src/Editor.svelte | 9 +- .../src/projections/ChangeProjection.svelte | 5 +- .../src/projections/ReplaceProjection.svelte | 9 +- .../src/projections/TrimProjection.svelte | 7 +- .../src/projections/changeProjection.ts | 2 +- package-lock.json | 34099 +++++----------- packages/codemirror-typescript/index.ts | 13 +- packages/codemirror-typescript/package.json | 13 +- packages/parser/package.json | 2 +- packages/projections/Keyword.svelte | 7 +- packages/projections/package.json | 12 +- packages/projections/shared.ts | 7 +- packages/projections/types.ts | 2 +- packages/simple-projection/index.ts | 5 +- packages/simple-projection/package.json | 9 +- packages/utils/package.json | 4 +- 33 files changed, 9725 insertions(+), 24693 deletions(-) diff --git a/apps/example/package.json b/apps/example/package.json index f34f8db3..239e2412 100644 --- a/apps/example/package.json +++ b/apps/example/package.json @@ -1,36 +1,37 @@ { "name": "@puredit/example", - "private": true, "version": "0.0.0", + "private": true, "type": "module", "scripts": { - "dev": "npm run prebuild && vite", + "prebuild": "npm run generate-dsl-declarations", "build": "vite build", - "preview": "vite preview", + "dev": "npm run prebuild && vite", + "generate-dsl-declarations": "dts-bundle-generator -o public/dsl.d.ts src/dsl/index.ts", "lint": "svelte-check --tsconfig ./tsconfig.json", - "prebuild": "npm run generate-dsl-declarations", - "generate-dsl-declarations": "dts-bundle-generator -o public/dsl.d.ts src/dsl/index.ts" + "preview": "vite preview" }, "dependencies": { - "@codemirror/autocomplete": "^0.19.13", - "@codemirror/basic-setup": "^0.19.1", - "@codemirror/commands": "^0.19.8", - "@codemirror/lint": "^0.19.5", - "@codemirror/state": "^0.19.9", - "@codemirror/theme-one-dark": "^0.19.1", - "@codemirror/tooltip": "^0.19.16", - "@codemirror/view": "^0.19.45", + "@codemirror/autocomplete": "6", + "@codemirror/commands": "6", + "@codemirror/lint": "6", + "@codemirror/state": "6", + "@codemirror/theme-one-dark": "6", + "@codemirror/view": "6", + "@lezer/highlight": "1", "@puredit/codemirror-typescript": "*", "@puredit/projections": "*", "@puredit/simple-projection": "*", "@puredit/utils": "*", - "@replit/codemirror-indentation-markers": "^0.19.1", + "@replit/codemirror-indentation-markers": "6", + "codemirror": "6", "normalize.css": "^8.0.1", "svelte-dark-mode": "^2.1.0" }, "devDependencies": { "@sveltejs/vite-plugin-svelte": "^1.1.0", "@tsconfig/svelte": "^3.0.0", + "@types/node": "^20.5.9", "dts-bundle-generator": "^6.5.0", "sass": "^1.53.0", "svelte": "^3.48.0", diff --git a/apps/example/src/Editor.svelte b/apps/example/src/Editor.svelte index 4b0b02ca..0e9f4cb6 100644 --- a/apps/example/src/Editor.svelte +++ b/apps/example/src/Editor.svelte @@ -1,8 +1,8 @@ - + diff --git a/packages/projections/package.json b/packages/projections/package.json index 7030b760..96d02878 100644 --- a/packages/projections/package.json +++ b/packages/projections/package.json @@ -1,16 +1,14 @@ { "name": "@puredit/projections", "version": "0.0.0", + "license": "MIT", "main": "./index.ts", "types": "./index.ts", - "license": "MIT", "dependencies": { - "@codemirror/autocomplete": "^0.19.13", - "@codemirror/highlight": "^0.19.7", - "@codemirror/language": "^0.19.7", - "@codemirror/state": "^0.19.9", - "@codemirror/text": "^0.19.6", - "@codemirror/view": "^0.19.45", + "@codemirror/autocomplete": "6", + "@codemirror/language": "6", + "@codemirror/state": "6", + "@codemirror/view": "6", "@puredit/parser": "*", "@types/string-similarity": "^4.0.0", "string-similarity": "^4.0.4" diff --git a/packages/projections/shared.ts b/packages/projections/shared.ts index beb55458..4c81f691 100644 --- a/packages/projections/shared.ts +++ b/packages/projections/shared.ts @@ -1,7 +1,8 @@ +import { tags } from "@lezer/highlight"; import type { EditorView } from "@codemirror/view"; -import { HighlightStyle, tags } from "@codemirror/highlight"; +import { highlightingFor } from "@codemirror/language"; import type { EditorState, ChangeSpec } from "@codemirror/state"; -import type { Text } from "@codemirror/text"; +import type { Text } from "@codemirror/state"; import type { Match, SyntaxNode } from "@puredit/parser"; import { ProjectionWidget } from "./projection"; @@ -75,7 +76,7 @@ export function bold(text: string): HTMLElement { export function keyword(text: string, state: EditorState): HTMLElement { const el = document.createElement("span"); - el.className = HighlightStyle.get(state, tags.keyword) || ""; + el.className = highlightingFor(state, [tags.keyword]) || ""; el.textContent = text; return el; } diff --git a/packages/projections/types.ts b/packages/projections/types.ts index 6be5961c..5948fa90 100644 --- a/packages/projections/types.ts +++ b/packages/projections/types.ts @@ -1,4 +1,4 @@ -import type { Text } from "@codemirror/text"; +import type { Text } from "@codemirror/state"; import type { Context, Match, Parser, PatternNode } from "@puredit/parser"; import type { ProjectionWidgetClass } from "./projection"; diff --git a/packages/simple-projection/index.ts b/packages/simple-projection/index.ts index 61caa3c5..1ab8466b 100644 --- a/packages/simple-projection/index.ts +++ b/packages/simple-projection/index.ts @@ -1,6 +1,7 @@ +import { tags } from "@lezer/highlight"; import { EditorSelection, EditorState } from "@codemirror/state"; import type { EditorView } from "@codemirror/view"; -import { HighlightStyle, tags } from "@codemirror/highlight"; +import { highlightingFor } from "@codemirror/language"; import type { Match, TemplateArg } from "@puredit/parser"; import { FocusGroup } from "@puredit/projections/focus"; import type { FocusGroupHandler } from "@puredit/projections/focus"; @@ -35,7 +36,7 @@ export const simpleProjection = ( const component = new TextInput({ target: element, props: { - className: HighlightStyle.get(state, tags.string), + className: highlightingFor(state, [tags.string]), node: match.args[args[0].name], targetNodes: args.length > 1 diff --git a/packages/simple-projection/package.json b/packages/simple-projection/package.json index bdb8b17c..14745a76 100644 --- a/packages/simple-projection/package.json +++ b/packages/simple-projection/package.json @@ -1,14 +1,13 @@ { "name": "@puredit/simple-projection", "version": "0.0.0", + "license": "MIT", "main": "./index.ts", "types": "./index.ts", - "license": "MIT", "dependencies": { - "@codemirror/highlight": "^0.19.7", - "@codemirror/language": "^0.19.7", - "@codemirror/state": "^0.19.9", - "@codemirror/view": "^0.19.45", + "@codemirror/language": "6", + "@codemirror/state": "6", + "@codemirror/view": "6", "@puredit/projections": "*", "@puredit/utils": "*" }, diff --git a/packages/utils/package.json b/packages/utils/package.json index 1b7898da..584bdbe0 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,8 +1,8 @@ { "name": "@puredit/utils", "version": "0.0.0", + "license": "MIT", "type": "module", "main": "./index.ts", - "types": "./index.ts", - "license": "MIT" + "types": "./index.ts" }