Duplicate the input text in the underlay div.
This commit is contained in:
parent
b52ee91745
commit
e6f16c854c
@ -10,6 +10,19 @@
|
|||||||
flex-basis: 0;
|
flex-basis: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
background: white;
|
background: white;
|
||||||
|
font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas,
|
||||||
|
"DejaVu Sans Mono", monospace;
|
||||||
|
font-weight: normal;
|
||||||
|
font-size: 3rem;
|
||||||
|
text-align: initial;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Editor-textarea,
|
||||||
|
.Editor-underlay {
|
||||||
|
font-family: inherit;
|
||||||
|
font-weight: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.Editor-textarea {
|
.Editor-textarea {
|
||||||
@ -21,6 +34,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
border: none;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,4 +48,5 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
/* background: orange; */
|
/* background: orange; */
|
||||||
|
/* color: purple; */
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
import './Editor.css';
|
import './Editor.css';
|
||||||
|
|
||||||
function Editor() {
|
function Editor({
|
||||||
|
defaultValue = "I have a text value."
|
||||||
|
}) {
|
||||||
function handleChange(event: React.ChangeEvent<HTMLTextAreaElement>) {
|
function handleChange(event: React.ChangeEvent<HTMLTextAreaElement>) {
|
||||||
console.log(event.target.value);
|
console.log(event.target.value);
|
||||||
|
setValue(event.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [value, setValue] = useState(defaultValue);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="Editor">
|
<div className="Editor">
|
||||||
<div className="Editor-textwrapper">
|
<div className="Editor-textwrapper">
|
||||||
<textarea onChange={handleChange} className="Editor-textarea">I have text</textarea>
|
<textarea onChange={handleChange} className="Editor-textarea" value={value} />
|
||||||
<div className="Editor-underlay"></div>
|
<div className="Editor-underlay">{value}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="Editor-ast"></div>
|
<div className="Editor-ast"></div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user