-
-
Notifications
You must be signed in to change notification settings - Fork 118
Keep LineBreaks in pasted code #132
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,8 +40,8 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P | |
addClosing: true, | ||
history: true, | ||
window: globalWindow, | ||
autoclose: { | ||
open: `([{'"`, | ||
autoclose: { | ||
open: `([{'"`, | ||
close: `)]}'"` | ||
}, | ||
...opt, | ||
|
@@ -149,9 +149,9 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P | |
|
||
function save(): Position { | ||
const s = getSelection() | ||
const pos: Position = {start: 0, end: 0, dir: undefined} | ||
const pos: Position = { start: 0, end: 0, dir: undefined } | ||
|
||
let {anchorNode, anchorOffset, focusNode, focusOffset} = s | ||
let { anchorNode, anchorOffset, focusNode, focusOffset } = s | ||
if (!anchorNode || !focusNode) throw 'error1' | ||
|
||
// If the anchor and focus are the editor element, return either a full | ||
|
@@ -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 | ||
pos.start = end | ||
pos.end = start | ||
} | ||
|
@@ -381,7 +381,7 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P | |
const pos = save() | ||
// Remove full length tab or just remaining padding | ||
const len = Math.min(options.tab.length, padding.length) | ||
restore({start, end: start + len}) | ||
restore({ start, end: start + len }) | ||
document.execCommand('delete') | ||
pos.start -= len | ||
pos.end -= len | ||
|
@@ -430,7 +430,7 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P | |
} | ||
|
||
at++ | ||
history[at] = {html, pos} | ||
history[at] = { html, pos } | ||
history.splice(at + 1) | ||
|
||
const maxHistory = 300 | ||
|
@@ -511,6 +511,7 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P | |
.replace(/>/g, '>') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, ''') | ||
.replace(/\n/g, '<br>') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about not-ff? Ib those plain-text mode \n is supported. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
document.execCommand('insertHTML', false, text) | ||
} | ||
|
||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.