From 8192c0b4f57382a331f82ba1637c166dab72f977 Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Wed, 3 Aug 2016 12:59:06 -0700 Subject: [PATCH] default matchers should run before users fix #843 --- modules/clipboard.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) 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: [] };