Skip to content

Conversation

aktion-hip
Copy link

Adjusted function insert(). Lines 507 ff:

function insert(text: string) {
    text = text
      .replace(/&/g, '&')
      .replace(/</g, '&lt;')
      .replace(/>/g, '&gt;')
      .replace(/"/g, '&quot;')
      .replace(/'/g, '&#039;')
      .replace(/\n/g, '<br>')
    document.execCommand('insertHTML', false, text)
  }

Added .replace(/\n/g, '<br>') to keep line breaks for content pasted into code input area.

@@ -223,7 +223,7 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P

// Flip start and end if the direction reversed
if (pos.dir == '<-') {
const {start, end} = pos
const { start, end } = pos
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets keep style as is for now

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for this change, that was not intended.

@@ -511,6 +511,7 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
.replace(/\n/g, '<br>')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about not-ff? Ib those plain-text mode \n is supported.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, this problem exists only using FF. I now can confirm that pasting multiline code works without problems using Edge or Chrome.

@black0ps2
Copy link

Can this be approved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants