Comments (6)
Don't set max height and overflow values on the editor directly. Wrap it in a div and set the overflow and height on that.
from react-simple-code-editor.
@devenovil have the same problem。do you have solve it?
nope, i didn't find any solution for fix this bug, yet @satya164 still not re-open this issue
from react-simple-code-editor.
@devenovil have the same problem。do you have solve it?
from react-simple-code-editor.
Owh thanks, for height it works, but for width it's not work, please re-check again and re-open this issue for horizontal wrap
from react-simple-code-editor.
@satya164 horizontal scrollBar still need to be solved。
from react-simple-code-editor.
I found a solution, you have to change textarea width and height dynamically. I'm using styled-components that's why I have variable inside CSS.
Add class to Editor to have the possibility to querySelector (tried with useRef hook but couldn't get scrollHeight from ref)
className="simple-editor"
Make two states (in my case initial width is multiplied by 0.55 because I want to cover 55% screen width by editor).
const [textareaHeight, setTextareaHeight] = useState(window.innerHeight);
const [textareaWidth, setTextareaWidth] = useState(window.innerWidth*0.55);
Each time you change the content, change the width and height of the textarea to the same as the editor itself (you can add deboucing)
useEffect(() => {
const editorHeight = document.querySelector('.simple-editor').scrollHeight;
const editorWidth = document.querySelector('.simple-editor').scrollWidth;
setTextareaHeight(editorHeight);
setTextareaWidth(editorWidth);
},[content])
You have to add following styles to the editor:
overflow: auto !important;
white-space: pre;
height: 100vh;
To the "pre" element inside Editor:
height: 100vh;
white-space: pre !important;
word-wrap: normal !important;
To the textarea inside Editor:
white-space: pre !important;
word-wrap: normal !important;
height: ${({ textareaHeight }) => textareaHeight}px!important;
width: ${({ textareaWidth }) => textareaWidth}px!important;
from react-simple-code-editor.
Related Issues (20)
- a11y: "Form control element <textarea> has no associated label" HOT 1
- demo is broken HOT 2
- Incorrect import with ESBuild bundling (must use <Editor.default ... />)
- styles.root.fontFamily inconsistent behavior
- pasting code inside Editor, breaks the component
- Token highlight issue in Google Chrome HOT 3
- Is it possible to unindent with Shift + Tab? HOT 1
- How can we add tooltip on highlight position?
- Doesn't it support multiple languages? HOT 2
- Getting "global is not defined" after configuring supabase
- highlight.js theme import doesn't work for some reason
- Editor not working as expected with android phone which changed text size
- How to get the code area resizable (like a textarea)? HOT 3
- FR: Autocomplete support
- Editor may not work well in all sizes
- Uncaught ReferenceError: global is not defined | React Typescript HOT 7
- Long text renders incorrectly HOT 4
- Cannot read property 'rest' of undefined HOT 1
- readonly HOT 2
- [Security] Workflow main.yaml is using vulnerable action actions/checkout
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-simple-code-editor.