Closed RohitBhati8269 closed 2 months ago
but it shows CR at the end of every line(which can be seen in the attached image).
If the CR is part of the line separator, it doesn't. If you set the line separator to "\n"
in a document that has "\r\n"
between the lines, yes, you'll see those return characters at the end of your lines.
but still If I start writing some text and add a new line then that new line comes as '\n' separator why?
That's not what I'm seeing when I test this. The document representation (state.doc
) does not know about line separators, but if you use state.sliceDoc()
or other line-break aware state methods you get your separator between the lines.
Everything working fine besides this:- As I have integrated a lineSeparator in my application, When I Copy a crlf text from outside and paste into my editor. It should change based on my current EOL. Vice-versa. But currently, it is not changing. Anything missing ?
When I Copy a crlf text from outside and paste into my editor. It should change based on my current EOL.
Did you set up a clipboard input filter?
(Again, you probably don't want to use the lineSeparator
option at all, from the way you're describing what you're trying to do, since you don't sound like you actually want rigidly enforced line endings at the document level. You may get better results by removing it, and only inserting the appropriate line separators on output.)
Yes i use clipboardInputFilter, i can fix this issue by just fetching text in clipboardInputFilter function and replace the text but I don't want to use replace() method.
Is there any way to handle this without using replace() method?
Is lineSeparator does not do handle this situation by default?
Is lineSeparator does not do handle this situation by default?
No it doesn't. It doesn't do what you seem to believe it does, at all. I recommend you stop using it, because it will not help you here.
Describe the issue
Trying to create a button to change CRLF/LF just like VSCode but showing CR at the end of the line.
I created a function
setLineSeparator
which calls when I hit the button to switch LF to CRLF or CRLF to LF. But when I switch from LF to CRLF it changes the lineBreak to\r\n
and also updates the lineSeprator value to\r\n
but it shows CR at the end of every line(which can be seen in the attached image).one more issue is that if lineBreaks and lineSeparator are both updated to
\r\n
but still If I start writing some text and add a new line then that new line comes as '\n' separator why?Code Snapshot:-
Browser and platform
No response
Reproduction link
No response