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

Feature/monaco #1450

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Feature/monaco #1450

wants to merge 23 commits into from

Conversation

bpoulaindev
Copy link
Contributor

Description

Integration of the Monaco Editor (same one that's powering Visual Studio Code)
This integration will provide a more user-friendly code editor for all of those used to Vs Code or IntelliJ.
It will also help us enhance the coding experience and make it easier to add our own custom commands later on.

Major benefits :

  • Autocompletion with the whole javascript ecosystem
  • Code tooltips for javascript AND bru, req and res commands
  • Horizontal scrolling for long lines
  • Links opening directly in the browser
  • Multiple themes (although i only selected 2 atm)
  • Better code search
Veed.Create.Edit.mp4

Closing issue #1339

Contribution Checklist:

  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

@bpoulaindev
Copy link
Contributor Author

Please don't merge it now, it's almost ready.
I added a tooltip to see variables in the URL but I'm currently experiencing re-renders and so there are duplicated values in the tooltip

@martinsefcik
Copy link
Contributor

I played a bit with this, but I still see a quite a lot of issues there:

  • is it possible to press enter in single line editor and create new lines

    Recording.2024-01-27.235635.mp4
  • variable names are not colored (red/green) based on defined/undefined
    image

  • if I move cursor over variable name then value is not displayed in tooltip but instead tooltip with info I can open url in browser with ctrl+click, do we need urls clickable in single line editor (e.g. in request url) or even in multiline editor ?
    image

  • background color of request url text field is the same as the rest of this area with method, save and run button (it does not look same for me as it is on your video, I'm not sure why)
    image

  • this minimap on right side is displayed also in single editor, probably in bruno it is not needed even for multi line editor
    image
    image

  • styling of whole editor is not good it is not clear where the editor area exactly is
    image


export const AppContext = React.createContext();

export const AppProvider = (props) => {
useTelemetry();
useIpcEvents();

// useCollectionNextAction();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove if not needed

@@ -165,7 +164,7 @@ class SingleLineEditor extends Component {
let variables = getAllVariables(this.props.collection);
this.variables = variables;

defineCodeMirrorBrunoVariablesMode(variables, 'text/plain');
// defineCodeMirrorBrunoVariablesMode(variables, 'text/plain');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove if not needed

@@ -41,26 +41,28 @@ const Script = ({ item, collection }) => {
return (
<StyledWrapper className="w-full flex flex-col">
<div className="flex-1 mt-2">
<div className="mb-1 title text-xs">Pre Request</div>
<CodeEditor
<h3 className="title text-xs mb-2">Pre Request</h3>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to h3, but the same Pre request title is also at least on request Vars tab. So would leave it as it was or change it everywhere to look the same.

<div className="mt-1 mb-1 title text-xs">Post Response</div>
<CodeEditor
<div className="flex-1 pb-6 mt-2">
<h3 className="mb-2 title text-xs">Post Response</h3>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to h3, but the same Post response title is also at least on request Vars tab. So would leave it as it was or change it everywhere to look the same.

@@ -5,22 +5,14 @@
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
/* import React from 'react';
Copy link
Contributor

@martinsefcik martinsefcik Jan 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove code (in whole file) if not needed instead of putting it in the comments.

@@ -18,6 +17,7 @@ import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collection
import StyledWrapper from './StyledWrapper';
import Documentation from 'components/Documentation/index';
import GraphQLSchemaActions from '../GraphQLSchemaActions/index';
import { MonacoEditor } from 'components/MonacoEditor';

const GraphQLRequestPane = ({ item, collection, leftPaneWidth, onSchemaLoad, toggleDocs, handleGqlClickReference }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess handleGqlClickReference could be removed if not needed anymore.

@bpoulaindev
Copy link
Contributor Author

Thanks for your feedback @martinsefcik , yes indeed i still have some fixes to do regarding the {{..}} syntax, i got it to work, my only issue is with the tooltip. I solved the single line issue and the background color, the border is a bit more difficult, i wanted to do it with pure tailwind classes but we're still in tailwind v2, we don't have child selectors enabled.
image

… variables in json not working, tooltip infinite re render
@bpoulaindev
Copy link
Contributor Author

Well i fixed a lot of stuff there but there are two things i can't make function properly :

  • Json with {{variable}}
  • variable in query url with http://prefix

@bpoulaindev
Copy link
Contributor Author

Great news, i managed to add dynamic tokenizer with custom colors, depending on the variable's status (see examples below) :
image
image
image
image

@bpoulaindev bpoulaindev marked this pull request as ready for review February 19, 2024 15:34
@bpoulaindev
Copy link
Contributor Author

bpoulaindev commented Feb 22, 2024

@helloanoop i added the changes you required, we can now switch between Monaco and Codemirror (codemirror is on by default)
image

Its-treason added a commit to Its-treason/bruno that referenced this pull request Mar 3, 2024
Its-treason added a commit to Its-treason/bruno that referenced this pull request Mar 5, 2024
Its-treason added a commit to Its-treason/bruno that referenced this pull request Mar 5, 2024
Its-treason added a commit to Its-treason/bruno that referenced this pull request Mar 6, 2024
Its-treason added a commit to Its-treason/bruno that referenced this pull request Mar 7, 2024
Its-treason added a commit to Its-treason/bruno that referenced this pull request May 11, 2024
- Better styling for singleline editor
- Multiline singleline editor
- Improved hover

Ref: usebruno#1450
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants