mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-12 22:25:24 +03:00
Add lazy loading
This commit is contained in:
parent
684399bacb
commit
1e5a1622fb
@ -1,6 +1,6 @@
|
||||
import { isDesktop } from "react-device-detect";
|
||||
import { MonacoEditor } from "./MonacoEditor";
|
||||
import { CodeMirrorEditor } from "./CodeMirrorEditor";
|
||||
import { lazy } from "react";
|
||||
import MonacoEditor from "./MonacoEditor";
|
||||
|
||||
/**
|
||||
* Provides an interface for a Code Editor, to enable easy swapping between different implementations
|
||||
@ -18,6 +18,6 @@ export type CodeEditorProps = {
|
||||
*
|
||||
* It would be great to revisit this in in the future if/when Monaco improves mobile support.
|
||||
*/
|
||||
export const CodeEditor: (props: CodeEditorProps) => JSX.Element = isDesktop
|
||||
export const CodeEditor: (props: CodeEditorProps) => React.ReactNode = isDesktop
|
||||
? MonacoEditor
|
||||
: CodeMirrorEditor;
|
||||
: lazy(() => import("./CodeMirrorEditor"));
|
||||
|
||||
@ -41,7 +41,7 @@ import { useTheme } from "@/context/theme-provider";
|
||||
* Uses `CodeMirror` as a code editor implementation.
|
||||
* Currently doesn't support yaml schema validation or linting.
|
||||
*/
|
||||
export function CodeMirrorEditor({
|
||||
export default function CodeMirrorEditor({
|
||||
initialContent,
|
||||
onDidChangeContent,
|
||||
}: Omit<CodeEditorProps, "schemaUrl">) {
|
||||
|
||||
@ -4,7 +4,7 @@ import { configureMonacoYaml } from "monaco-yaml";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { CodeEditorProps } from "./CodeEditor";
|
||||
|
||||
export function MonacoEditor({
|
||||
export default function MonacoEditor({
|
||||
initialContent,
|
||||
yamlSchemaUrl,
|
||||
onDidChangeContent,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user