Added line wrap feature in expanded editor
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React, {useState, useEffect, useLayoutEffect} from 'react';
|
import React, {useState, useEffect, useLayoutEffect} from 'react';
|
||||||
import {
|
import {
|
||||||
IconButton,
|
IconButton,
|
||||||
Dialog,
|
Dialog,
|
||||||
Modal,
|
Modal,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
@@ -8,6 +8,9 @@ import {
|
|||||||
DialogContent
|
DialogContent
|
||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
|
|
||||||
|
import Checkbox from '@mui/material/Checkbox';
|
||||||
|
import { orange } from '@mui/material/colors';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
FullscreenExit as FullscreenExitIcon,
|
FullscreenExit as FullscreenExitIcon,
|
||||||
} from "@material-ui/icons";
|
} from "@material-ui/icons";
|
||||||
@@ -27,10 +30,11 @@ import 'codemirror/theme/gruvbox-dark.css';
|
|||||||
const CodeEditor = (props) => {
|
const CodeEditor = (props) => {
|
||||||
const { fieldCount, setFieldCount, actionlist, changeActionParameterCodeMirror, expansionModalOpen, setExpansionModalOpen, codedata, setcodedata } = props
|
const { fieldCount, setFieldCount, actionlist, changeActionParameterCodeMirror, expansionModalOpen, setExpansionModalOpen, codedata, setcodedata } = props
|
||||||
const [localcodedata, setlocalcodedata] = React.useState(codedata === undefined || codedata === null || codedata.length === 0 ? "" : codedata);
|
const [localcodedata, setlocalcodedata] = React.useState(codedata === undefined || codedata === null || codedata.length === 0 ? "" : codedata);
|
||||||
// const {codelang, setcodelang} = props
|
// const {codelang, setcodelang} = props
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [validation, setValidation] = React.useState(false);
|
const [validation, setValidation] = React.useState(false);
|
||||||
const [expOutput, setExpOutput] = React.useState(" ");
|
const [expOutput, setExpOutput] = React.useState(" ");
|
||||||
|
const [linewrap, setlinewrap] = React.useState(true);
|
||||||
|
|
||||||
const autoFormat = (input) => {
|
const autoFormat = (input) => {
|
||||||
if (validation !== true) {
|
if (validation !== true) {
|
||||||
@@ -129,13 +133,14 @@ const CodeEditor = (props) => {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span style={{
|
<span style={{
|
||||||
border: `2px solid ${theme.palette.inputColor}`,
|
border: `2px solid ${theme.palette.inputColor}`,
|
||||||
borderRadius: theme.palette.borderRadius,
|
borderRadius: theme.palette.borderRadius,
|
||||||
}}>
|
}}>
|
||||||
<CodeMirror
|
<CodeMirror
|
||||||
value = {localcodedata}
|
value = {localcodedata}
|
||||||
height="250px"
|
height="200px"
|
||||||
style={{
|
style={{
|
||||||
}}
|
}}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
@@ -146,11 +151,48 @@ const CodeEditor = (props) => {
|
|||||||
theme: 'gruvbox-dark',
|
theme: 'gruvbox-dark',
|
||||||
keyMap: 'sublime',
|
keyMap: 'sublime',
|
||||||
mode: 'javascript',
|
mode: 'javascript',
|
||||||
|
lineWrapping: linewrap,
|
||||||
// mode: {codelang},
|
// mode: {codelang},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginBottom: -30,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
fontFamily: "monospace",
|
||||||
|
paddingLeft: 480,
|
||||||
|
width: 100,
|
||||||
|
display: 'inline',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Line Wrap
|
||||||
|
<Checkbox
|
||||||
|
onClick={() => {
|
||||||
|
if (linewrap) {
|
||||||
|
setlinewrap(false)
|
||||||
|
}
|
||||||
|
if (!linewrap){
|
||||||
|
setlinewrap(true)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
defaultChecked
|
||||||
|
size="small"
|
||||||
|
sx={{
|
||||||
|
color: orange[600],
|
||||||
|
'&.Mui-checked': {
|
||||||
|
color: orange[800],
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<DialogTitle
|
<DialogTitle
|
||||||
style={{
|
style={{
|
||||||
@@ -172,8 +214,8 @@ const CodeEditor = (props) => {
|
|||||||
theme={theme.palette.jsonTheme}
|
theme={theme.palette.jsonTheme}
|
||||||
style={{
|
style={{
|
||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
border: "1px solid rgba(255,255,255,0.7)",
|
border: `2px solid ${theme.palette.inputColor}`,
|
||||||
padding: 5,
|
padding: 10,
|
||||||
maxHeight: 250,
|
maxHeight: 250,
|
||||||
minheight: 250,
|
minheight: 250,
|
||||||
overflow: "auto",
|
overflow: "auto",
|
||||||
|
|||||||
Generated
+16
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"requires": true,
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"dependencies": {
|
||||||
|
"codemirror": {
|
||||||
|
"version": "5.65.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.65.0.tgz",
|
||||||
|
"integrity": "sha512-gWEnHKEcz1Hyz7fsQWpK7P0sPI2/kSkRX2tc7DFA6TmZuDN75x/1ejnH/Pn8adYKrLEA1V2ww6L00GudHZbSKw=="
|
||||||
|
},
|
||||||
|
"react-codemirror-runmode": {
|
||||||
|
"version": "1.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-codemirror-runmode/-/react-codemirror-runmode-1.0.5.tgz",
|
||||||
|
"integrity": "sha512-6TzbODi0WSllc0VOwOjTpZxE9wUheMMpmBNydzR5o0NbbBLX0j73xutH/o85BTG9NKs06sFEBMvCsRKT6jRz8A=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user