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

[WEB-480] fix: code block paste from VSCode and indentation #4198

Merged
merged 242 commits into from
Apr 16, 2024

Conversation

Palanikannan1437
Copy link
Collaborator

@Palanikannan1437 Palanikannan1437 commented Apr 15, 2024

Description

This PR intends to add proper copy pasting behaviour of content copied from VSCode into our editor into a code block, while handling vaaarious scenarios...

  1. If copied code from VSCode is pasted into a inline code block, it stays an inline code block
  2. If cursor is at an empty node, then the copied code from VSCode will be converted into a code block and the code block is inserted into the current line itself
  3. If cursor is not in an empty node, then the copied code from VSCode will be converted into a code block and the code block is inserted into the next line

Some more improvements w.r.t to toggling code blocks,

  1. When you toggle a codeBlock, the formatting along with the indentation is maintained by the following parsing logic
      const lines = textContent.split(/\r?\n/);
      const parsedContent = lines.map((line) => `<p>${line.replace(/ /g, "&nbsp;")}</p>`).join("");
  1. When you select a bunch of lines and hit toggle code button from menubar, then it'll turn into a codeBlock instead of inline code.
  2. From within a code block, if you click toggle, then with all the indentation as is and line breaks, it'll be turned into normal paragraphs.
  3. If you select a single line/word and press toggle, then the text is wrapped around by inline code block....

NarayanBavisetti and others added 30 commits February 13, 2024 13:17
@Palanikannan1437 Palanikannan1437 force-pushed the fix/code-block-vs-code-handler branch from e31a6ea to 282b735 Compare April 16, 2024 04:55
@Palanikannan1437 Palanikannan1437 marked this pull request as ready for review April 16, 2024 09:24
@Palanikannan1437 Palanikannan1437 added this to the v0.18.0-dev milestone Apr 16, 2024
@Palanikannan1437 Palanikannan1437 marked this pull request as draft April 16, 2024 09:30
@Palanikannan1437 Palanikannan1437 marked this pull request as ready for review April 16, 2024 09:42
@pushya22 pushya22 changed the title fix: code block paste from VSCode and indentation [WEB-480] fix: code block paste from VSCode and indentation Apr 16, 2024
@Palanikannan1437 Palanikannan1437 force-pushed the fix/code-block-vs-code-handler branch from 0fcaec6 to 0d57267 Compare April 16, 2024 12:37
@sriramveeraghanta sriramveeraghanta merged commit 27db869 into develop Apr 16, 2024
10 of 11 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix/code-block-vs-code-handler branch April 16, 2024 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants