From 64910cdbaf87e4079caeb8aa69a8189627842efb Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Thu, 31 Aug 2017 12:29:03 -0700 Subject: [PATCH] fixes #1624 --- modules/clipboard.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/clipboard.js b/modules/clipboard.js index 5fe2c30fae..eb0727277c 100644 --- a/modules/clipboard.js +++ b/modules/clipboard.js @@ -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'; @@ -76,6 +77,12 @@ class Clipboard extends Module { this.container.innerHTML = html.replace(/\>\r?\n +\<'); // 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