Skip to content

Commit

Permalink
fix #844, fix #845 and test
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Aug 3, 2016
1 parent 836ab2a commit 1ec6e6e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function expandConfig(container, userConfig) {
throw new Error(`Invalid theme ${userConfig.theme}. Did you register it?`);
}
}
let themeConfig = extend(true, {}, Theme.DEFAULTS);
let themeConfig = extend(true, {}, userConfig.theme.DEFAULTS);
[themeConfig, userConfig].forEach(function(config) {
config.modules = config.modules || {};
Object.keys(config.modules).forEach(function(module) {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/core/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Quill, { expandConfig, overload } from '../../../core/quill';
import Theme from '../../../core/theme';
import Emitter from '../../../core/emitter';
import Toolbar from '../../../modules/toolbar';
import Snow from '../../../themes/snow';
import { Range } from '../../../core/selection';


Expand Down Expand Up @@ -286,6 +287,17 @@ describe('Quill', function() {
Theme.DEFAULTS.modules = oldModules;
});

it('theme defaults', function() {
let config = expandConfig('#test-container', {
modules: {
toolbar: true,
},
theme: 'snow'
});
expect(config.theme).toEqual(Snow);
expect(config.modules.toolbar.handlers.image).toEqual(Snow.DEFAULTS.modules.toolbar.handlers.image);
});

it('quill < module < theme < user', function() {
let oldTheme = Theme.DEFAULTS.modules;
let oldToolbar = Toolbar.DEFAULTS;
Expand Down

0 comments on commit 1ec6e6e

Please sign in to comment.