From 1ec45e5ad6436d36d3951a75663b4f310025d765 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 26 Aug 2024 22:31:23 +0200 Subject: [PATCH] feat: add vim support for monaco/webeditor --- .github/DockerfileBackendTests | 2 +- .../windmill-worker/src/python_executor.rs | 2 +- frontend/package-lock.json | 26 +++++++ frontend/package.json | 5 +- frontend/src/lib/assets/app.css | 4 + frontend/src/lib/components/DiffEditor.svelte | 6 +- frontend/src/lib/components/Editor.svelte | 34 ++++++++- frontend/src/lib/components/EditorBar.svelte | 13 +--- .../src/lib/components/EditorSettings.svelte | 47 ++++++++++++ .../src/lib/components/FormatOnSave.svelte | 43 +++-------- .../src/lib/components/ScriptBuilder.svelte | 3 + .../src/lib/components/ScriptEditor.svelte | 1 + .../src/lib/components/SimpleEditor.svelte | 34 ++++++++- .../src/lib/components/TemplateEditor.svelte | 2 +- frontend/src/lib/components/VimMode.svelte | 18 +++++ .../inlineScriptsPanel/CacheTtlPopup.svelte | 1 + .../InlineScriptEditor.svelte | 3 + .../copilot/CodeCompletionStatus.svelte | 73 +++++++------------ frontend/src/lib/components/custom_ui.ts | 3 +- .../flows/content/ScriptEditorDrawer.svelte | 3 + .../src/lib/components/monaco_keybindings.ts | 14 ++++ frontend/src/lib/stores.ts | 13 +++- frontend/vite.config.js | 2 +- python-client/wmill/wmill/client.py | 2 +- 24 files changed, 250 insertions(+), 104 deletions(-) create mode 100644 frontend/src/lib/components/EditorSettings.svelte create mode 100644 frontend/src/lib/components/VimMode.svelte create mode 100644 frontend/src/lib/components/monaco_keybindings.ts diff --git a/.github/DockerfileBackendTests b/.github/DockerfileBackendTests index b56e64d085..3050e9ab54 100644 --- a/.github/DockerfileBackendTests +++ b/.github/DockerfileBackendTests @@ -1,5 +1,5 @@ ARG DEBIAN_IMAGE=debian:bookworm-slim -ARG RUST_IMAGE=rust:1.79-slim-bookworm +ARG RUST_IMAGE=rust:1.80-slim-bookworm ARG PYTHON_IMAGE=python:3.11.4-slim-bookworm FROM ${DEBIAN_IMAGE} as downloader diff --git a/backend/windmill-worker/src/python_executor.rs b/backend/windmill-worker/src/python_executor.rs index 3186bd41c5..8d33a057b3 100644 --- a/backend/windmill-worker/src/python_executor.rs +++ b/backend/windmill-worker/src/python_executor.rs @@ -318,7 +318,7 @@ def to_b_64(v: bytes): b64 = base64.b64encode(v) return b64.decode('ascii') -replace_nan = re.compile(r'(?:\bNaN\b|\\u0000)') +replace_nan = re.compile(r'(?:\bNaN\b|\\*\\u0000)') result_json = os.path.join(os.path.abspath(os.path.dirname(__file__)), "result.json") diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 6999e54e4f..7aaeb8a75e 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,28 @@ { "name": "windmill-components", +<<<<<<< Updated upstream "version": "1.385.0", +======= +<<<<<<< Updated upstream + "version": "1.384.0", +======= + "version": "1.383.9", +>>>>>>> Stashed changes +>>>>>>> Stashed changes "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "windmill-components", +<<<<<<< Updated upstream "version": "1.385.0", +======= +<<<<<<< Updated upstream + "version": "1.384.0", +======= + "version": "1.383.9", +>>>>>>> Stashed changes +>>>>>>> Stashed changes "license": "AGPL-3.0", "dependencies": { "@aws-crypto/sha256-js": "^4.0.0", @@ -49,6 +65,7 @@ "monaco-editor-wrapper": "^5.5.2", "monaco-graphql": "^1.6.0", "monaco-languageclient": "~8.8.2", + "monaco-vim": "^0.4.1", "ol": "^7.4.0", "openai": "^4.47.1", "p-limit": "^6.1.0", @@ -9736,6 +9753,15 @@ } } }, + "node_modules/monaco-vim": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/monaco-vim/-/monaco-vim-0.4.1.tgz", + "integrity": "sha512-+cy0TE9xarjLIgUexqxIEbat3K1l7WbiFSLZKAO2kYl1qFRvkeWn4ro/C4c6dK0i9+WQKUC4Dhu/nyCbZfA37w==", + "license": "MIT", + "peerDependencies": { + "monaco-editor": "*" + } + }, "node_modules/mri": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index 33bda3df10..f8d1ceb79e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,7 +17,6 @@ "filter-classes": "node filterTailwindClasses.js" }, "devDependencies": { - "@windmill-labs/esbuild-import-meta-url-plugin": "0.0.0-semantic-release", "@floating-ui/core": "^1.3.1", "@hey-api/openapi-ts": "^0.43.0", "@playwright/test": "^1.34.3", @@ -35,6 +34,7 @@ "@types/vscode": "^1.83.5", "@typescript-eslint/eslint-plugin": "^5.59.8", "@typescript-eslint/parser": "^5.60.0", + "@windmill-labs/esbuild-import-meta-url-plugin": "0.0.0-semantic-release", "@zerodevx/svelte-toast": "^0.9.5", "autoprefixer": "^10.4.13", "cssnano": "^6.0.1", @@ -88,9 +88,9 @@ "@codingame/monaco-vscode-keybindings-service-override": "~8.0.2", "@codingame/monaco-vscode-lifecycle-service-override": "~8.0.2", "@codingame/monaco-vscode-localization-service-override": "~8.0.2", + "@codingame/monaco-vscode-standalone-css-language-features": "~8.0.2", "@codingame/monaco-vscode-standalone-json-language-features": "~8.0.2", "@codingame/monaco-vscode-standalone-languages": "~8.0.2", - "@codingame/monaco-vscode-standalone-css-language-features": "~8.0.2", "@codingame/monaco-vscode-standalone-typescript-language-features": "~8.0.2", "@json2csv/plainjs": "^7.0.6", "@leeoniya/ufuzzy": "^1.0.8", @@ -122,6 +122,7 @@ "monaco-editor-wrapper": "^5.5.2", "monaco-graphql": "^1.6.0", "monaco-languageclient": "~8.8.2", + "monaco-vim": "^0.4.1", "ol": "^7.4.0", "openai": "^4.47.1", "p-limit": "^6.1.0", diff --git a/frontend/src/lib/assets/app.css b/frontend/src/lib/assets/app.css index e86a21190f..069b58e827 100644 --- a/frontend/src/lib/assets/app.css +++ b/frontend/src/lib/assets/app.css @@ -120,3 +120,7 @@ svelte-virtual-list-contents > * + * { @apply bg-surface; @apply disabled:placeholder:text-gray-200 disabled:placeholder:dark:text-gray-500 disabled:text-gray-200 disabled:dark:text-gray-500 disabled:border-gray-200 disabled:dark:border-gray-600; } + +.nonmain-editor .cursor.monaco-mouse-cursor-text { + width: 1px !important; +} diff --git a/frontend/src/lib/components/DiffEditor.svelte b/frontend/src/lib/components/DiffEditor.svelte index 379f84908f..4be144c70a 100644 --- a/frontend/src/lib/components/DiffEditor.svelte +++ b/frontend/src/lib/components/DiffEditor.svelte @@ -125,5 +125,9 @@ {#if open} -
+
{/if} diff --git a/frontend/src/lib/components/Editor.svelte b/frontend/src/lib/components/Editor.svelte index 40162d432e..0d2617f2be 100644 --- a/frontend/src/lib/components/Editor.svelte +++ b/frontend/src/lib/components/Editor.svelte @@ -3,7 +3,6 @@ + +{#if customUi?.autoformatting != false || customUi?.vimMode != false || customUi?.aiCompletion != false} + + +
{/if} -
+
+{#if allowVim && $vimMode} +
+{/if}