mirror of
https://github.com/ershisan99/DevToysWeb.git
synced 2025-12-17 12:32:56 +00:00
chore: upgrade to react 19 beta and next 14 canary
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import { ComponentProps } from "react";
|
||||
import MonacoEditor from "@monaco-editor/react";
|
||||
import { useTheme } from "next-themes";
|
||||
|
||||
export type EditorProps = React.ComponentPropsWithoutRef<typeof MonacoEditor>;
|
||||
// @ts-expect-error react 19 beta error
|
||||
export type EditorProps = ComponentProps<typeof MonacoEditor>;
|
||||
|
||||
/**
|
||||
* NOTE: This component maybe doesn't shrink according to the container component's width
|
||||
@@ -12,26 +13,28 @@ export type EditorProps = React.ComponentPropsWithoutRef<typeof MonacoEditor>;
|
||||
* @see https://github.com/suren-atoyan/monaco-react/issues/346
|
||||
*
|
||||
*/
|
||||
export const Editor = React.forwardRef<HTMLTextAreaElement, EditorProps>(
|
||||
({ options, theme, ...props }, ref) => {
|
||||
const { theme: appTheme } = useTheme();
|
||||
const themeToUse = theme ?? (appTheme === "light" ? "light" : "vs-dark");
|
||||
// @ts-expect-error react 19 beta error
|
||||
export const Editor = ({ options, theme, ...props }: EditorProps) => {
|
||||
const { theme: appTheme } = useTheme();
|
||||
const themeToUse = theme ?? (appTheme === "light" ? "light" : "vs-dark");
|
||||
|
||||
return (
|
||||
<MonacoEditor
|
||||
{...{ ref }}
|
||||
theme={themeToUse}
|
||||
options={{
|
||||
tabFocusMode: true,
|
||||
detectIndentation: false,
|
||||
minimap: { enabled: false },
|
||||
automaticLayout: true,
|
||||
scrollBeyondLastLine: false,
|
||||
...options, // NOTE: merge shallowly
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
);
|
||||
Editor.displayName = "Editor";
|
||||
return (
|
||||
// @ts-expect-error react 19 beta error
|
||||
<MonacoEditor
|
||||
// @ts-expect-error react 19 beta error
|
||||
theme={themeToUse}
|
||||
// @ts-expect-error react 19 beta error
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
options={{
|
||||
tabFocusMode: true,
|
||||
detectIndentation: false,
|
||||
minimap: { enabled: false },
|
||||
automaticLayout: true,
|
||||
scrollBeyondLastLine: false,
|
||||
// @ts-expect-error react 19 beta error
|
||||
...options, // NOTE: merge shallowly
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user