Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy-pasted file containing newlines, newlines did not appear until after refreshing #341

Open
rbohrer opened this issue May 27, 2023 · 2 comments
Assignees
Labels
defect Something isn't working as intended writing Related to book authoring.
Milestone

Comments

@rbohrer
Copy link

rbohrer commented May 27, 2023

FIle attached. To reproduce, copy-paste it into a fresh chapter, look at the editor UI, then refresh.
Note I made this file in Notepad on Windows and I'm assuming it has CRLF line endings
TestNewline.txt

@amyjko amyjko self-assigned this Jun 10, 2023
@amyjko amyjko added defect Something isn't working as intended writing Related to book authoring. labels Jun 10, 2023
@amyjko amyjko added this to the 1.0 milestone Jun 10, 2023
@amyjko
Copy link
Owner

amyjko commented Jun 10, 2023

This definitely isn't the expected behavior. Here's a bit of brainstorming about how to address it.

When pasting raw text, BookishEditor.handlePaste() takes a single text node ad inserts it into the lowest part of the document tree, climbing up the parents until it finds a node willing to insert it. But in doing so, it ignores any whitespace in the text node. This works on refresh because when that node is serialized, the whitespace is preserved, and on reload, it's parsed appropriately as separate paragraphs.

There are a few possible solutions here:

  1. Split the raw text into multiple text nodes and insert them as a list. This would require a major revision to the insertion algorithm, since it only accepts a single node at the moment, not a list of nodes. It might also ignore any parsing logic.

  2. Insert the text node as we do now, but then reparse, accounting for the whitespace. This would account for all parsing rules, but just require some careful handling of the caret placement.

I'm leaning towards the second option.

@rbohrer
Copy link
Author

rbohrer commented Jun 12, 2023 via email

@amyjko amyjko moved this to Backlog in Bookish 1.0 Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Something isn't working as intended writing Related to book authoring.
Projects
Status: Backlog
Development

No branches or pull requests

2 participants