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

Blank Lines Cannot Get Copied and Pasted #269

Open
d-e-v-esh opened this issue Feb 26, 2021 · 11 comments
Open

Blank Lines Cannot Get Copied and Pasted #269

d-e-v-esh opened this issue Feb 26, 2021 · 11 comments
Assignees

Comments

@d-e-v-esh
Copy link
Contributor

Bug Report 🐛

When we copy a block of text from one place to another, the text is copied properly but the blank lines between them are not getting copied. This makes formatting more annoying.

Expected Behavior

Osf0jOE0xw

Current Behavior

AkPqpXwcp8

Possible Solution

Steps to Reproduce

  1. Write two lines of text and create few blank lines between them.
  2. Copy that block of text which will also contain the blank lines and paste it down below
  3. You will see that the pasted text will not have blank lines between them.

Context (Environment)

Desktop

  • OS: Windows 10
  • Browser: Chrome
  • Version 88.0.4324.182 (Official Build) (64-bit)

Detailed Description

Possible Implementation

@Michael-Grover Michael-Grover added the Type: Bug 🐛 Something isn't working label Feb 26, 2021
@Michael-Grover
Copy link

@irmerk @jeromesimeon is this because markdown doesn't preserve white space?

@Michael-Grover
Copy link

It's my understanding that if a user were able to save this document and reopen it, any white space like line breaks would be removed when the document is reopened

@jeromesimeon
Copy link
Member

@irmerk @jeromesimeon is this because markdown doesn't preserve white space?

I am not sure. This could be an artefact of markdown (there is no way to create random space between paragraphs), or a bug in copy paste. This might need investigation.

@d-e-v-esh
Copy link
Contributor Author

@jeromesimeon I think it was probably because of how the line was being created. I did some tests and now it works fine.

@jolanglinais
Copy link
Member

We'll need to do a thorough investigation on all of this to see what is going on, the limitations, and what these changes do.

@dselman
Copy link
Contributor

dselman commented Mar 1, 2021

Copy/paste uses the Slate <--> CiceroMark <--> HTML transformation, so it is likely that markdown insignificant whitespace is getting dropped. Perhaps we can be smarter at representing blank paras when we convert from Slate to CiceroMark?

@dselman
Copy link
Contributor

dselman commented Mar 1, 2021

Using this input Slate document:

{
    "document": {
      "object": "document",
      "children": [
        {
          "object": "block",
          "data": {},
          "type": "heading_one",
          "children": [
            {
              "object": "text",
              "text": "Heading"
            }
          ]
        },
        {
          "object": "block",
          "type": "paragraph",
          "children": [
            {
              "object": "text",
              "text": "This is some text."
            }
          ],
          "data": {}
        },
        {
            "object": "block",
            "type": "paragraph",
            "children": [
              {
                "object": "text",
                "text": ""
              }
            ],
            "data": {}
          },
        {
          "object": "block",
          "type": "paragraph",
          "children": [
            {
              "object": "text",
              "text": "This is more text."
            }
          ],
          "data": {}
        }
      ],
      "data": {}
    }
  }  

And running:

markus transform --input slate.json --from slate --to html

The following HTML is produced:

<html>
<body>
<div class="document">
<h1>Heading</h1>
<p>This is some text.</p>
<p>This is more text.</p>
</div>
</body>
</html>

Showing that the Slate paragraph containing an empty text node got removed during the transformation from Slate to ciceromark_parsed.

@d-e-v-esh
Copy link
Contributor Author

d-e-v-esh commented Mar 1, 2021

@dselman What should be the proper solution to this? I didn't pay much attention to this problem and kind of tinkered here and there with few things until it worked.

@dselman
Copy link
Contributor

dselman commented Mar 1, 2021

This line removes empty paragraphs when converting from Slate to CiceroMark:

https://github.com/accordproject/markdown-transform/blob/f68f7a33dece4d106c6a17a698b1f411441ef0d9/packages/markdown-slate/lib/slateToCiceroMarkDom.js#L86

While this handles the conversion from CiceroMark to Slate:

https://github.com/accordproject/markdown-transform/blob/master/packages/markdown-slate/lib/ToSlateVisitor.js#L532

CiceroMark whitespace handling should be consistent with markdown (i.e. whitespace is not significant), however you can force a hard line break in markdown using \ (see output from https://spec.commonmark.org/dingus/ using the markdown below)

## Try CommonMark

This is 1

This is 2.
\
\
\
\
This is 3

So, one approach would be to replace empty paragraphs in the Slate DOM with hard line breaks in the CiceroMark DOM (and vice-a-versa, to preserve roundtripping).

@jolanglinais
Copy link
Member

@dselman that sounds like something that needs to come from @accordproject/markdown-transform?

@dselman
Copy link
Contributor

dselman commented Mar 2, 2021

Agreed. I will move the discussion to this issue: accordproject/markdown-transform#362

@dselman dselman closed this as completed Mar 2, 2021
@dselman dselman reopened this Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants