diff --git a/modules/clipboard.js b/modules/clipboard.js index 5c1df5b99b..854c5eb27b 100644 --- a/modules/clipboard.js +++ b/modules/clipboard.js @@ -14,6 +14,17 @@ import { SizeStyle } from '../formats/size'; let debug = logger('quill:clipboard'); +const CLIPBOARD_CONFIG = [ + [Node.TEXT_NODE, matchText], + ['br', matchBreak], + [Node.ELEMENT_NODE, matchNewline], + [Node.ELEMENT_NODE, matchBlot], + [Node.ELEMENT_NODE, matchSpacing], + [Node.ELEMENT_NODE, matchAttributor], + [Node.ELEMENT_NODE, matchStyles], + ['b', matchAlias.bind(matchAlias, 'bold')], + ['i', matchAlias.bind(matchAlias, 'italic')] +]; const STYLE_ATTRIBUTORS = [ AlignStyle, @@ -36,7 +47,7 @@ class Clipboard extends Module { this.container.setAttribute('contenteditable', true); this.container.setAttribute('tabindex', -1); this.matchers = []; - this.options.matchers.forEach((pair) => { + CLIPBOARD_CONFIG.concat(this.options.matchers).forEach((pair) => { this.addMatcher(...pair); }); } @@ -118,17 +129,7 @@ class Clipboard extends Module { } } Clipboard.DEFAULTS = { - matchers: [ - [Node.TEXT_NODE, matchText], - ['br', matchBreak], - [Node.ELEMENT_NODE, matchNewline], - [Node.ELEMENT_NODE, matchBlot], - [Node.ELEMENT_NODE, matchSpacing], - [Node.ELEMENT_NODE, matchAttributor], - [Node.ELEMENT_NODE, matchStyles], - ['b', matchAlias.bind(matchAlias, 'bold')], - ['i', matchAlias.bind(matchAlias, 'italic')] - ] + matchers: [] };