From 40aca4d35bf56eaeddc48436922e20d727cddc24 Mon Sep 17 00:00:00 2001 From: James George <25279263+jamesgeorge007@users.noreply.github.com> Date: Fri, 25 Jul 2025 13:35:37 +0530 Subject: [PATCH] feat: move scripting code editors to use Monaco (#5191) Replaces CodeMirror with Monaco for scripting editors under the experimental scripting sandbox. The legacy CodeMirror-based editors are preserved for backwards compatibility and will continue to power the legacy scripting sandbox. This introduces improved type support, IntelliSense, and JSDoc hinting via Monaco, with the backing for pre-request and post-request scripts in tabbed views. Type definitions are isolated per editor to avoid variable leakage. --- packages/hoppscotch-common/package.json | 2 + .../src/components/MonacoScriptEditor.vue | 196 ++++++++++++++++++ .../src/components/http/PreRequestScript.vue | 55 +++-- .../src/components/http/RequestOptions.vue | 44 +++- .../src/components/http/Tests.vue | 46 ++-- packages/hoppscotch-common/src/index.ts | 26 ++- .../src/types/post-request.d.ts | 35 ++++ .../src/types/pre-request.d.ts | 9 + packages/hoppscotch-selfhost-web/package.json | 2 +- .../hoppscotch-selfhost-web/vite.config.ts | 2 +- pnpm-lock.yaml | 57 +++-- 11 files changed, 416 insertions(+), 58 deletions(-) create mode 100644 packages/hoppscotch-common/src/components/MonacoScriptEditor.vue create mode 100644 packages/hoppscotch-common/src/types/post-request.d.ts create mode 100644 packages/hoppscotch-common/src/types/pre-request.d.ts diff --git a/packages/hoppscotch-common/package.json b/packages/hoppscotch-common/package.json index 51ff3b13..29adfba0 100644 --- a/packages/hoppscotch-common/package.json +++ b/packages/hoppscotch-common/package.json @@ -34,6 +34,7 @@ "@codemirror/search": "6.5.6", "@codemirror/state": "6.4.1", "@codemirror/view": "6.25.1", + "@guolao/vue-monaco-editor": "1.5.5", "@hoppscotch/codemirror-lang-graphql": "workspace:^", "@hoppscotch/data": "workspace:^", "@hoppscotch/httpsnippet": "3.0.9", @@ -79,6 +80,7 @@ "lossless-json": "4.0.2", "markdown-it": "14.1.0", "minisearch": "7.1.0", + "monaco-editor": "0.52.2", "nprogress": "0.2.0", "paho-mqtt": "1.1.0", "path": "0.12.7", diff --git a/packages/hoppscotch-common/src/components/MonacoScriptEditor.vue b/packages/hoppscotch-common/src/components/MonacoScriptEditor.vue new file mode 100644 index 00000000..0545d564 --- /dev/null +++ b/packages/hoppscotch-common/src/components/MonacoScriptEditor.vue @@ -0,0 +1,196 @@ + + + diff --git a/packages/hoppscotch-common/src/components/http/PreRequestScript.vue b/packages/hoppscotch-common/src/components/http/PreRequestScript.vue index 0cf1caaf..fba723da 100644 --- a/packages/hoppscotch-common/src/components/http/PreRequestScript.vue +++ b/packages/hoppscotch-common/src/components/http/PreRequestScript.vue @@ -38,7 +38,18 @@
-
+ + +