aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/Inputs/Code.js
blob: e313152399219ce37df39e0faefd92cb88702509 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import React from "react";
import CharLimit from "../decorators/CharLimit";
import {Labelled} from "../decorators/Labelled";
import Editor from 'react-simple-code-editor';
import {Highlighter} from "../renderers/Code";

export const Code = ({content, id, readOnly, setContentCallback, ...props}) => {
  return (
    <Labelled
      label="content"
      id={id}
      value={content}>
        <Editor
          name="content"
          readOnly={readOnly}
          placeholder="Paste your text here"
          value={content}
          id={id}
          required
          highlight={code => <Highlighter theme="atom">{code}</Highlighter> }
          onValueChange={code => setContentCallback(code)}
          padding={10}
          style={{
            fontFamily: '"JetBrains Mono", monospace',
            fontSize: 12,
          }}
        />
        <CharLimit
          content={content}
          maxLength={props.maxLength} />
    </Labelled>
  );
}