Skip to content

Commit

Permalink
fixes #1624
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Aug 31, 2017
1 parent 38c4c9e commit 64910cd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Module from '../core/module';

import { AlignAttribute, AlignStyle } from '../formats/align';
import { BackgroundStyle } from '../formats/background';
import CodeBlock from '../formats/code';
import { ColorStyle } from '../formats/color';
import { DirectionAttribute, DirectionStyle } from '../formats/direction';
import { FontStyle } from '../formats/font';
Expand Down Expand Up @@ -76,6 +77,12 @@ class Clipboard extends Module {
this.container.innerHTML = html.replace(/\>\r?\n +\</g, '><'); // Remove spaces between tags
return this.convert();
}
const formats = this.quill.getFormat(this.quill.selection.savedRange.index);
if (formats[CodeBlock.blotName]) {
const text = this.container.innerText;
this.container.innerHTML = '';
return new Delta().insert(text, { [CodeBlock.blotName]: formats[CodeBlock.blotName] });
}
let [elementMatchers, textMatchers] = this.prepareMatching();
let delta = traverse(this.container, elementMatchers, textMatchers);
// Remove trailing newline
Expand Down

0 comments on commit 64910cd

Please sign in to comment.