question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pasted Empty Lines Are Duplicated

See original GitHub issue

Describe the Bug

Pasting an empty line when editing a label results in two empty lines upon rendering. Even though direct editing and the properties panel use the same fix empty lines are duplicated upon rendering a label.

d2JyZCUUK2

Steps to Reproduce

  1. Copy this text
Foo

Bar
Baz
  1. Paste it into the direct editing box when editing a label
  2. Complete direct editing
  3. Rendered text is now
Foo


Bar
Baz

Expected Behavior

Empty lines are neither lost nor duplicated.

Environment

  • OS: Windows 10
  • Camunda Modeler Version: 4.9.0-rc.4

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
Skaiircommented, Aug 15, 2022

Have done some investigations, and have fully RCA’d this:

  • Copy paste isn’t the culprit
  • The problem lies within the chromium implementation of https://github.com/bpmn-io/diagram-js-direct-editing/blob/78fe92019daad3ca27f97f187dc5ceb0abcdaccc/lib/TextBox.js#L218
    • This is an educated guess, because I have not found an issue reference for this, and neither have I gone into the chromium source code 🤡, if that’s even accessible
    • The issue is not present on Firefox is the major tell here, but it is present on the Desktop modeler and on Chrome itself
    • The issue presents itself immediately after the execution of the presented line of code
  • What is happening here is that under certain circumstances, namely copying newlines and pasting them on top of other newlines via (not all scenarios but most), in chrome, <divs> are created:

image

Solution proposal:

We could simply sanitize the divs out, if we ever want to include rich text in the labels, this might come back to bite us but from my research combining richText with document.execCommand('insertText' is not advisable anyways and is very buggy.

ExecCommand as it stands is deprecated, but there is no good alternative to this. The clipboard API does not have a replacement function for insertText.

We could also have our own implementation for chromium based browsers, like we do with IE, but that would be a much larger time investment.

@nikku @philippfromme Opinions?

1reaction
philippfrommecommented, Jul 7, 2021

It’s the same in Camunda Modeler 4.8.1

Okay, so this issue is not related to https://github.com/camunda/camunda-modeler/issues/2280. Thanks, @barmac, with v4.8.1 on Windows I wasn’t able to test this as empty lines were lost on paste.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pasting text adds new line between each line · Issue #1454 ...
I expect the file to paste as I have copied it, with no extra spaces or new lines added. Actual behavior. The pasted...
Read more >
Quickly Remove Blanks and Duplicates in Microsoft Excel
In this Microsoft Excel tutorial, I will show you how to remove blank rows, cells, and duplicates. This method with Go to Special...
Read more >
Copying a file without duplicate and blank lines in Python
This writes to 'file2.txt' all lines in 'file1.txt' apart from those that are made up of only whitespace or that are duplicates.
Read more >
Copy paste in code block double the empty lines
Hello, When I copy code from an editor (Notepad+++, PyCharm etc.) and paste it into an Evernote code block, all empty lines are...
Read more >
How to copy and paste values skipping duplicates in Excel?
1. Select the column range you need to copy and paste values skipping duplicates, and click Data > Filter. Then click the Advanced...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found