adiabhiraj195 / feather-docs

MIT License
0 stars 0 forks source link

reverse text in draft #1

Open adiabhiraj195 opened 9 months ago

adiabhiraj195 commented 9 months ago

The text editor doesn't work properly, it represents text in reverse order Or type in reverse https://github.com/adiabhiraj195/feather-docs/blob/master/client/src/context/editor-context.tsx

CCleanerShot commented 9 months ago

Usually when you work with an input value, you don't re-render the component like you are currently doing:

 const updatedDocument = {
            ...document,
            content: JSON.stringify(content)
        } as DocumentInterface;
        setDocument(updatedDocument);

This is because, as you can notice, certain properties like your current cursor location is reset. If you have a purpose for updating the state (I had the same desire sometime back), you're going to basically have to keep track of previous settings of what was happening. Here:

https://stackoverflow.com/questions/46000544/react-controlled-input-cursor-jumps

adiabhiraj195 commented 9 months ago

How i can do it with draft?? Its value is stored in type EditorState and it doesn't contains properties same as input element