-
-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): add function editor theme, json editor, app model
* feat: add function editor theme & component * feat: add depnedence panel * feat: add database json editor * update: function page content * refactor: page container * feat: create app modal
- Loading branch information
Showing
46 changed files
with
1,568 additions
and
1,175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { useEffect } from "react"; | ||
import { CopyIcon } from "@chakra-ui/icons"; | ||
import { useClipboard, useToast } from "@chakra-ui/react"; | ||
|
||
export default function CopyText(props: { text: string }) { | ||
const { onCopy, setValue } = useClipboard(""); | ||
const toast = useToast(); | ||
|
||
const text = props.text; | ||
useEffect(() => { | ||
setValue(text); | ||
}, [setValue, text]); | ||
|
||
return ( | ||
<CopyIcon | ||
onClick={() => { | ||
onCopy(); | ||
toast({ | ||
position: "bottom", | ||
title: "复制成功", | ||
status: "success", | ||
duration: 600, | ||
}); | ||
}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useEffect } from "react"; | ||
import Editor, { useMonaco } from "@monaco-editor/react"; | ||
|
||
export default function FunctionEditor(props: { value: string }) { | ||
const { value } = props; | ||
const monaco = useMonaco(); | ||
|
||
monaco?.editor.defineTheme("lafEditorTheme", { | ||
base: "vs", | ||
inherit: true, | ||
rules: [], | ||
colors: { | ||
"editorLineNumber.foreground": "#aaa", | ||
"editorOverviewRuler.border": "#fff", | ||
"editor.lineHighlightBackground": "#F5F6F8", | ||
"scrollbarSlider.background": "#E8EAEC", | ||
"editorIndentGuide.activeBackground": "#ddd", | ||
"editorIndentGuide.background": "#eee", | ||
}, | ||
}); | ||
|
||
useEffect(() => { | ||
setTimeout(() => { | ||
monaco?.editor.setTheme("lafEditorTheme"); | ||
}, 0); | ||
}, [monaco]); | ||
|
||
return ( | ||
<Editor | ||
options={{ | ||
automaticLayout: true, | ||
minimap: { | ||
enabled: false, | ||
}, | ||
scrollbar: { | ||
verticalScrollbarSize: 6, | ||
}, | ||
lineNumbersMinChars: 4, | ||
fontSize: "14px", | ||
// fontFamily: "monospace", | ||
scrollBeyondLastLine: false, | ||
}} | ||
height="100%" | ||
defaultLanguage="javascript" | ||
value={value} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { useEffect } from "react"; | ||
import Editor, { useMonaco } from "@monaco-editor/react"; | ||
|
||
export default function JsonEditor(props: { value: string | object }) { | ||
const { value } = props; | ||
const monaco = useMonaco(); | ||
|
||
monaco?.editor.defineTheme("lafJsonEditorTheme", { | ||
base: "vs", | ||
inherit: true, | ||
rules: [], | ||
colors: { | ||
"editorLineNumber.foreground": "#aaa", | ||
"editorOverviewRuler.border": "#fff", | ||
"editor.lineHighlightBackground": "#F5F6F8", | ||
"scrollbarSlider.background": "#E8EAEC", | ||
"editorIndentGuide.activeBackground": "#ddd", | ||
"editorIndentGuide.background": "#eee", | ||
}, | ||
}); | ||
|
||
useEffect(() => { | ||
setTimeout(() => { | ||
monaco?.editor.setTheme("lafJsonEditorTheme"); | ||
}, 0); | ||
}, [monaco]); | ||
|
||
return ( | ||
<Editor | ||
language="json" | ||
value={JSON.stringify(value, null, 2)} | ||
width={"600"} | ||
height="100%" | ||
options={{ | ||
lineNumber: false, | ||
guides: { | ||
indentation: false, | ||
}, | ||
minimap: { | ||
enabled: false, | ||
}, | ||
lineHighlightBackground: "red", | ||
scrollbar: { | ||
verticalScrollbarSize: 0, | ||
alwaysConsumeMouseWheel: false, | ||
}, | ||
lineNumbers: "off", | ||
lineNumbersMinChars: 0, | ||
fontSize: 14, | ||
scrollBeyondLastLine: false, | ||
folding: false, | ||
overviewRulerBorder: false, | ||
tabSize: 2, // tab 缩进长度 | ||
}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useCallback, useEffect } from "react"; | ||
|
||
function useHotKey(keyMap: string, trigger: () => void) { | ||
const handleKeyDown = useCallback( | ||
(event: any) => { | ||
if (event.key === keyMap && (event.ctrlKey || event.metaKey)) { | ||
event.preventDefault(); | ||
|
||
// remove test log when api called | ||
trigger(); | ||
} | ||
}, | ||
[keyMap, trigger], | ||
); | ||
|
||
useEffect(() => { | ||
// attach the event listener | ||
document.addEventListener("keydown", handleKeyDown); | ||
|
||
// remove the event listener | ||
return () => { | ||
document.removeEventListener("keydown", handleKeyDown); | ||
}; | ||
}, [handleKeyDown]); | ||
|
||
return "⌘" + keyMap; | ||
} | ||
|
||
export default useHotKey; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.