550 | {props.showLineNumber &&
}
551 |
{
553 | textAreaRef.current = r?._input;
554 | preElementRef.current = textAreaRef.current?.nextElementSibling as HTMLPreElement;
555 | }}
556 | value={code}
557 | disabled={shouldForbiddenEdit}
558 | placeholder={props.placeholder}
559 | onValueChange={setCode}
560 | highlight={(code: string) => {
561 | return highlight(code);
562 | }}
563 | padding={8}
564 | style={{
565 | flex: 1,
566 | height: '100%',
567 | fontFamily: 'SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace',
568 | fontSize: 14,
569 | lineHeight: 1.5,
570 | ...props.style,
571 | }}
572 | />
573 |
574 | );
575 | }),
576 | );
577 |
--------------------------------------------------------------------------------
/src/json5-editor/style.less:
--------------------------------------------------------------------------------
1 | @namespace: ~'json5-editor-wrapper';
2 |
3 | .@{namespace} {
4 | min-height: 200px;
5 | height: 100%;
6 | cursor: text;
7 | display: flex;
8 |
9 | div,
10 | textarea {
11 | outline: none;
12 | }
13 | textarea,
14 | pre {
15 | min-height: 200px;
16 | }
17 |
18 | // line numbers
19 | .line-numbers-rows {
20 | box-sizing: border-box;
21 | font-size: 14px;
22 | letter-spacing: -1px;
23 | border-right: 1px solid #e8e8e8;
24 | padding: 8px 0;
25 | user-select: none;
26 | font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
27 | height: fit-content;
28 | background-color: rgba(0, 0, 0, 0.03);
29 | min-height: 200px;
30 | color: #999;
31 | min-width: 38px;
32 | line-height: 1;
33 |
34 | & > .errorLine {
35 | background: rgba(255, 77, 79, 0.9);
36 | color: #ffffff;
37 |
38 | & > .errorMessage {
39 | display: none;
40 | }
41 |
42 | &:hover > .errorMessage {
43 | display: inline-block;
44 | width: 0;
45 | max-width: 0;
46 | margin: 0;
47 | overflow: visible;
48 | transform: translate(8px, 1px);
49 | z-index: 1;
50 |
51 | & > span {
52 | z-index: 1;
53 | padding: 4px 8px;
54 | background: #57606f;
55 | word-break: break-all;
56 | white-space: pre;
57 | position: relative;
58 | overflow: visible;
59 | }
60 | }
61 | }
62 |
63 | & > span {
64 | padding: 0 8px;
65 | height: 21px;
66 | display: flex;
67 | align-items: flex-start;
68 | justify-content: space-between;
69 | cursor: pointer;
70 | & > code {
71 | position: relative;
72 | top: 2px;
73 | }
74 | & > span {
75 | position: relative;
76 | top: 1px;
77 | margin-left: 6px;
78 | }
79 | }
80 | }
81 |
82 | border: 1px solid #e8e8e8;
83 | &.@{namespace}-has-error {
84 | border: 1px solid rgba(255, 77, 79, 0.5);
85 | }
86 |
87 | &.@{namespace}-disabled {
88 | cursor: not-allowed;
89 | background-color: #f5f5f5;
90 | border-color: #e8e8e8;
91 | &:hover {
92 | border-color: #e8e8e8;
93 | }
94 | }
95 |
96 | overflow: auto;
97 | transition: all 0.3s;
98 |
99 | &:hover {
100 | border: 1px solid rgba(64, 169, 255, 0.5);
101 | }
102 | &.@{namespace}-has-error:hover {
103 | border: 1px solid rgb(255, 77, 79);
104 | }
105 | &:focus-within {
106 | border-color: #40a9ff;
107 | border-right-width: 1px !important;
108 | outline: 0;
109 | box-shadow: 0 0 0 2px rgb(24 144 255 / 20%);
110 | }
111 |
112 | .token.error {
113 | background-color: rgba(0, 0, 0, 0.1);
114 | }
115 | .token.punctuation {
116 | color: #595959;
117 | }
118 | .token.punctuation.active {
119 | outline: 1px solid rgba(0, 0, 0, 0.25);
120 | }
121 | .token.indent {
122 | &::after {
123 | position: absolute;
124 | content: url("data:image/svg+xml;utf-8,