suren-atoyan / monaco-react

Monaco Editor for React - use the monaco-editor in any React application without needing to use webpack (or rollup/parcel/etc) configuration files / plugins
https://monaco-react.surenatoyan.com/
MIT License
3.82k stars 269 forks source link

Default json value not formatted on mounted #649

Closed jpainam closed 1 month ago

jpainam commented 1 month ago

Hi. I'm unable to format the default json value on mouted.

Here is my code

"use client";

import { useRef } from "react";
import { Editor } from "@monaco-editor/react";

export const MyEditor = ({
  onChange,
  defaultValue,
}: {
  onChange?: (value: string | null | undefined) => void;
  defaultValue?: string;
}) => {
  return (
      <Editor
        height={"200px"}
        defaultValue={defaultValue}
        language="json"
        defaultLanguage="json"
        onChange={(v) => onChange?.(v)}
        options={{
          minimap: { enabled: false },
          lineNumbers: "on",
          scrollbar: {
            vertical: "hidden",
            horizontal: "hidden",
          },
        }}
      />
  );
};

And here is the result image

Is it possible to format the default json value?

Thanks.

chenyingkeai commented 1 month ago

maybe you can refer to this issue, its helpful to me https://github.com/suren-atoyan/monaco-react/issues/11

suren-atoyan commented 1 month ago

maybe you can refer to this issue, its helpful to me #11

I am glad you found it helpful. I am closing this now, feel free to reopen if you face other issues related to this