From a058afeb069d7682c3584cc6f90e14d422215c11 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sun, 27 May 2018 22:22:38 +0200 Subject: [PATCH] Adjust imports --- package.json | 5 ++++- src/asset_manager/view/FileUploader.js | 2 ++ src/block_manager/view/BlockView.js | 1 + src/block_manager/view/CategoryView.js | 3 ++- src/commands/view/CommandAbstract.js | 1 + src/css_composer/view/CssRulesView.js | 3 ++- src/device_manager/view/DevicesView.js | 3 ++- src/dom_components/view/ComponentView.js | 1 + src/dom_components/view/ComponentsView.js | 1 + src/domain_abstract/ui/Input.js | 1 + src/domain_abstract/ui/InputColor.js | 4 +++- src/panels/view/ButtonView.js | 1 + src/selector_manager/view/ClassTagsView.js | 3 ++- src/style_manager/model/Layer.js | 2 ++ src/style_manager/model/Layers.js | 1 + src/style_manager/view/LayerView.js | 2 ++ src/style_manager/view/PropertiesView.js | 1 + src/style_manager/view/PropertyCompositeView.js | 1 + src/style_manager/view/PropertyFileView.js | 1 + src/style_manager/view/PropertyIntegerView.js | 1 + src/style_manager/view/PropertySelectView.js | 1 + src/style_manager/view/PropertyView.js | 1 + src/style_manager/view/SectorView.js | 3 ++- src/style_manager/view/SectorsView.js | 1 + src/trait_manager/view/TraitSelectView.js | 2 +- src/utils/ColorPicker.js | 6 ++---- test/helper.js | 1 - test/main.test.js | 2 +- test/specs/css_composer/e2e/CssComposer.js | 1 + test/specs/dom_components/model/Component.js | 1 + 30 files changed, 43 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index fc6eb86515..e0f1535acb 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,10 @@ ] }, "jest": { - "modulePaths": ["./src"] + "modulePaths": ["./src"], + "moduleNameMapper": { + "^jquery$": "cash-dom" + } }, "scripts": { "lint": "eslint src", diff --git a/src/asset_manager/view/FileUploader.js b/src/asset_manager/view/FileUploader.js index 970cd29bd6..d125845556 100644 --- a/src/asset_manager/view/FileUploader.js +++ b/src/asset_manager/view/FileUploader.js @@ -1,3 +1,5 @@ +import _ from 'underscore'; +import Backbone from 'backbone'; import fetch from 'utils/fetch'; module.exports = Backbone.View.extend( diff --git a/src/block_manager/view/BlockView.js b/src/block_manager/view/BlockView.js index 79eff55122..ac7a904a64 100644 --- a/src/block_manager/view/BlockView.js +++ b/src/block_manager/view/BlockView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; import { isObject } from 'underscore'; import { on, off, hasDnd } from 'utils/mixins'; diff --git a/src/block_manager/view/CategoryView.js b/src/block_manager/view/CategoryView.js index dc42081c9d..ca01bb2676 100644 --- a/src/block_manager/view/CategoryView.js +++ b/src/block_manager/view/CategoryView.js @@ -1,4 +1,5 @@ -var Backbone = require('backbone'); +import _ from 'underscore'; +import Backbone from 'backbone'; module.exports = Backbone.View.extend({ template: _.template(` diff --git a/src/commands/view/CommandAbstract.js b/src/commands/view/CommandAbstract.js index 3c21dc5c81..96e23f69cf 100644 --- a/src/commands/view/CommandAbstract.js +++ b/src/commands/view/CommandAbstract.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const $ = Backbone.$; module.exports = Backbone.View.extend({ diff --git a/src/css_composer/view/CssRulesView.js b/src/css_composer/view/CssRulesView.js index 6bf40869d7..91381f6cd5 100644 --- a/src/css_composer/view/CssRulesView.js +++ b/src/css_composer/view/CssRulesView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const CssRuleView = require('./CssRuleView'); const CssGroupRuleView = require('./CssGroupRuleView'); const $ = Backbone.$; @@ -6,7 +7,7 @@ const $ = Backbone.$; const getBlockId = (pfx, widthMedia) => `${pfx}${widthMedia ? `-${widthMedia.replace('%', 'pc')}` : ''}`; -module.exports = require('backbone').View.extend({ +module.exports = Backbone.View.extend({ initialize(o) { const config = o.config || {}; this.atRules = {}; diff --git a/src/device_manager/view/DevicesView.js b/src/device_manager/view/DevicesView.js index 9da83e16bb..b8b6c396e6 100644 --- a/src/device_manager/view/DevicesView.js +++ b/src/device_manager/view/DevicesView.js @@ -1,4 +1,5 @@ -var Backbone = require('backbone'); +import _ from 'underscore'; +import Backbone from 'backbone'; module.exports = Backbone.View.extend({ template: _.template(` diff --git a/src/dom_components/view/ComponentView.js b/src/dom_components/view/ComponentView.js index d3c8109fdf..29cf256df4 100644 --- a/src/dom_components/view/ComponentView.js +++ b/src/dom_components/view/ComponentView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; import { isArray, isEmpty } from 'underscore'; const ComponentsView = require('./ComponentsView'); diff --git a/src/dom_components/view/ComponentsView.js b/src/dom_components/view/ComponentsView.js index 45fb2f9dae..12e46091ec 100644 --- a/src/dom_components/view/ComponentsView.js +++ b/src/dom_components/view/ComponentsView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; import { isUndefined } from 'underscore'; module.exports = Backbone.View.extend({ diff --git a/src/domain_abstract/ui/Input.js b/src/domain_abstract/ui/Input.js index a4796c3c3b..fe6b479a36 100644 --- a/src/domain_abstract/ui/Input.js +++ b/src/domain_abstract/ui/Input.js @@ -1,3 +1,4 @@ +const Backbone = require('backbone'); const $ = Backbone.$; module.exports = Backbone.View.extend({ diff --git a/src/domain_abstract/ui/InputColor.js b/src/domain_abstract/ui/InputColor.js index 19469539da..1cfc7c0f8d 100644 --- a/src/domain_abstract/ui/InputColor.js +++ b/src/domain_abstract/ui/InputColor.js @@ -1,8 +1,10 @@ +import Backbone from 'backbone'; import { isUndefined } from 'underscore'; +import ColorPicker from 'utils/ColorPicker'; -require('utils/ColorPicker'); const Input = require('./Input'); const $ = Backbone.$; +ColorPicker($); module.exports = Input.extend({ template() { diff --git a/src/panels/view/ButtonView.js b/src/panels/view/ButtonView.js index 287fae240f..6dde7fef1b 100644 --- a/src/panels/view/ButtonView.js +++ b/src/panels/view/ButtonView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; import { isString, isObject, isFunction } from 'underscore'; const $ = Backbone.$; diff --git a/src/selector_manager/view/ClassTagsView.js b/src/selector_manager/view/ClassTagsView.js index aa7756f906..ebe6efeca3 100644 --- a/src/selector_manager/view/ClassTagsView.js +++ b/src/selector_manager/view/ClassTagsView.js @@ -1,4 +1,5 @@ -var Backbone = require('backbone'); +import _ from 'underscore'; +import Backbone from 'backbone'; var ClassTagView = require('./ClassTagView'); module.exports = Backbone.View.extend({ diff --git a/src/style_manager/model/Layer.js b/src/style_manager/model/Layer.js index 2a99e9fff5..5f113620ef 100644 --- a/src/style_manager/model/Layer.js +++ b/src/style_manager/model/Layer.js @@ -1,3 +1,5 @@ +import Backbone from 'backbone'; + module.exports = Backbone.Model.extend({ defaults: { index: '', diff --git a/src/style_manager/model/Layers.js b/src/style_manager/model/Layers.js index 3411d683cc..d3a7a08186 100644 --- a/src/style_manager/model/Layers.js +++ b/src/style_manager/model/Layers.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const Layer = require('./Layer'); module.exports = Backbone.Collection.extend({ diff --git a/src/style_manager/view/LayerView.js b/src/style_manager/view/LayerView.js index 50810ca5f6..6fef83f5b9 100644 --- a/src/style_manager/view/LayerView.js +++ b/src/style_manager/view/LayerView.js @@ -1,3 +1,5 @@ +import Backbone from 'backbone'; + module.exports = Backbone.View.extend({ events: { click: 'active', diff --git a/src/style_manager/view/PropertiesView.js b/src/style_manager/view/PropertiesView.js index 2791c21e62..e0fa8b0888 100644 --- a/src/style_manager/view/PropertiesView.js +++ b/src/style_manager/view/PropertiesView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const PropertyView = require('./PropertyView'); const PropertyIntegerView = require('./PropertyIntegerView'); const PropertyRadioView = require('./PropertyRadioView'); diff --git a/src/style_manager/view/PropertyCompositeView.js b/src/style_manager/view/PropertyCompositeView.js index e3f456eabd..c05b5a7d9b 100644 --- a/src/style_manager/view/PropertyCompositeView.js +++ b/src/style_manager/view/PropertyCompositeView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const PropertyView = require('./PropertyView'); const $ = Backbone.$; diff --git a/src/style_manager/view/PropertyFileView.js b/src/style_manager/view/PropertyFileView.js index 8114adb85f..06021b4967 100644 --- a/src/style_manager/view/PropertyFileView.js +++ b/src/style_manager/view/PropertyFileView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const PropertyView = require('./PropertyView'); const $ = Backbone.$; diff --git a/src/style_manager/view/PropertyIntegerView.js b/src/style_manager/view/PropertyIntegerView.js index 6518a9d4fe..b2d19fbf51 100644 --- a/src/style_manager/view/PropertyIntegerView.js +++ b/src/style_manager/view/PropertyIntegerView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const InputNumber = require('domain_abstract/ui/InputNumber'); const PropertyView = require('./PropertyView'); const $ = Backbone.$; diff --git a/src/style_manager/view/PropertySelectView.js b/src/style_manager/view/PropertySelectView.js index f235e081bd..3b3fdde7f1 100644 --- a/src/style_manager/view/PropertySelectView.js +++ b/src/style_manager/view/PropertySelectView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const $ = Backbone.$; module.exports = require('./PropertyView').extend({ diff --git a/src/style_manager/view/PropertyView.js b/src/style_manager/view/PropertyView.js index c4d55990fd..9e79395ba3 100644 --- a/src/style_manager/view/PropertyView.js +++ b/src/style_manager/view/PropertyView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; import { bindAll, isArray, isUndefined } from 'underscore'; import { camelCase } from 'utils/mixins'; diff --git a/src/style_manager/view/SectorView.js b/src/style_manager/view/SectorView.js index 807083f194..c01b25b886 100644 --- a/src/style_manager/view/SectorView.js +++ b/src/style_manager/view/SectorView.js @@ -1,4 +1,5 @@ -var Backbone = require('backbone'); +import _ from 'underscore'; +import Backbone from 'backbone'; var PropertiesView = require('./PropertiesView'); module.exports = Backbone.View.extend({ diff --git a/src/style_manager/view/SectorsView.js b/src/style_manager/view/SectorsView.js index 0f0e82e027..2c38587600 100644 --- a/src/style_manager/view/SectorsView.js +++ b/src/style_manager/view/SectorsView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; import { extend } from 'underscore'; const SectorView = require('./SectorView'); diff --git a/src/trait_manager/view/TraitSelectView.js b/src/trait_manager/view/TraitSelectView.js index ca51ecdecc..7fac7c22c6 100644 --- a/src/trait_manager/view/TraitSelectView.js +++ b/src/trait_manager/view/TraitSelectView.js @@ -1,5 +1,5 @@ const TraitView = require('./TraitView'); -const $ = Backbone.$; +const $ = require('backbone').$; module.exports = TraitView.extend({ initialize(o) { diff --git a/src/utils/ColorPicker.js b/src/utils/ColorPicker.js index d3eacce10d..0d2d6e229c 100644 --- a/src/utils/ColorPicker.js +++ b/src/utils/ColorPicker.js @@ -5,9 +5,7 @@ // Author: Brian Grinstead // License: MIT -(function(factory) { - factory(Backbone.$); -})(function($, undefined) { +export default function($, undefined) { 'use strict'; var defaultOpts = { @@ -2531,4 +2529,4 @@ $.fn.spectrum.processNativeColorInputs(); } }); -}); +} diff --git a/test/helper.js b/test/helper.js index 6231ba6e16..13207b510b 100644 --- a/test/helper.js +++ b/test/helper.js @@ -1,5 +1,4 @@ import _ from 'underscore'; -import expect from 'expect'; import sinon from 'sinon'; import { JSDOM } from 'jsdom'; diff --git a/test/main.test.js b/test/main.test.js index 4c0a3bf801..ddbb4ae840 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -3,7 +3,7 @@ import grapesjs from './../src'; describe('Main', () => { describe('Startup', () => { it('Main object should be loaded', () => { - expect(grapesjs).toExist(); + expect(grapesjs).toBeTruthy(); }); }); diff --git a/test/specs/css_composer/e2e/CssComposer.js b/test/specs/css_composer/e2e/CssComposer.js index 07cf704712..99a4e9f8b7 100644 --- a/test/specs/css_composer/e2e/CssComposer.js +++ b/test/specs/css_composer/e2e/CssComposer.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const $ = Backbone.$; module.exports = { diff --git a/test/specs/dom_components/model/Component.js b/test/specs/dom_components/model/Component.js index c3ced43f34..a1d702cad2 100644 --- a/test/specs/dom_components/model/Component.js +++ b/test/specs/dom_components/model/Component.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; const DomComponents = require('dom_components'); const Component = require('dom_components/model/Component'); const ComponentImage = require('dom_components/model/ComponentImage');