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

Blocks: pasting formatting lists removes spacing #4702

Closed
bogdancondorachi opened this issue Sep 26, 2022 · 3 comments · Fixed by #5758
Closed

Blocks: pasting formatting lists removes spacing #4702

bogdancondorachi opened this issue Sep 26, 2022 · 3 comments · Fixed by #5758
Assignees
Labels
type: bug 🐛 Is a bug; fixes a bug
Milestone

Comments

@bogdancondorachi
Copy link

Description

When you try to paste/import some text from your clipboard that has lists that are formatted, the text of the list is rendered without the spaces around the formatted text.

Expected behavior
The text of the list should be kept exactly as copied

Screenshots

dashboard-hastyai-and-78-more-pages-personal-microsoft-edge-2022-09-26-20_95qugzXK.mp4

To reproduce

  1. Go on panel to a page that has blocks
  2. Add some test list with list block
  3. Add formatting to some words like bold, link
  4. Save and open page
  5. Copy the frontend rendered list
  6. ctrl+v or paste on the blocks again
  7. You should see that the same text appear without spaces around the words you've formatted

Your setup

Kirby Version
3.7.5

Console output
nothing on console

Your system (please complete the following information)

  • Device: Laptop
  • OS: Windows 11
  • Browser: Edge
  • Version: 105.0.1343.50

Additional context
It seems that if I add a list block then paste the text inside it, it will render as it should. Only when trying the ctrl+v function seems to not work.

@afbora afbora added the type: bug 🐛 Is a bug; fixes a bug label Sep 26, 2022
@afbora
Copy link
Member

afbora commented Oct 2, 2022

Issue summary

@bastianallgeier I've tracked down the issue and this issue occurs by following trim function
https://github.com/getkirby/kirby/blob/3.8.0-rc.2/src/Parsley/Inline.php#L31

Works great when I removed the trim but I'm not sure about the solution. You know better since you're author of Parsley class.

@distantnative
Copy link
Member

@afbora could you set up a PR with that fix? And then we can do more manual testing if we run into other side effects.

@afbora
Copy link
Member

afbora commented Dec 12, 2022

I understand exactly what the problem is, but I have no idea of a solution.
@bastianallgeier can you help me with this? Here is the process of issue:

  1. This method is executed for block list items on paste:
    https://github.com/getkirby/kirby/blob/3.8.3/src/Parsley/Schema/Blocks.php#L189
  2. For each dom element in each line, the following line is executed:
    https://github.com/getkirby/kirby/blob/3.8.3/src/Parsley/Schema/Blocks.php#L200
  3. The Inline class then deletes the space at the beginning and end of each dom element:
    https://github.com/getkirby/kirby/blob/3.8.3/src/Parsley/Inline.php#L31
  4. Then each dom element is joined adjacent to each other:
    https://github.com/getkirby/kirby/blob/3.8.3/src/Parsley/Schema/Blocks.php#L202-L206
  5. Thus the spaces between dom elements are lost.

When we remove trim function in Inline class, the ones with a single element are broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Is a bug; fixes a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants