Browse Source

Add imports-loader

no-jquery
Artur Arseniev 9 years ago
parent
commit
191ae0c4d3
  1. 1
      package.json
  2. 10
      src/commands/view/OpenStyleManager.js
  3. 5
      test/helper.js
  4. 2
      test/main.js
  5. 15
      test/specs/grapesjs/index.js
  6. 17
      test/specs/modal/view/ModalView.js
  7. 5
      test/specs/selector_manager/index.js
  8. 8
      webpack.config.js
  9. 11
      yarn.lock

1
package.json

@ -33,6 +33,7 @@
"documentation": "^5.3.0",
"eslint": "^4.1.1",
"expect": "^1.20.2",
"imports-loader": "^0.7.1",
"istanbul": "^0.4.2",
"jsdom": "^11.2.0",
"mocha": "^3.1.2",

10
src/commands/view/OpenStyleManager.js

@ -1,16 +1,18 @@
var StyleManager = require('style_manager');
const StyleManager = require('style_manager');
const Backbone = require('backbone');
const $ = Backbone.$;
module.exports = {
run(em, sender) {
this.sender = sender;
if(!this.$cn){
if (!this.$cn) {
var config = em.getConfig(),
panels = em.Panels;
// Main container
this.$cn = $('<div/>');
this.$cn = $('<div></div>');
// Secondary container
this.$cn2 = $('<div/>');
this.$cn2 = $('<div></div>');
this.$cn.append(this.$cn2);
// Device Manager

5
test/helper.js

@ -46,7 +46,10 @@ global.navigator = {
};
// Need this to trigger the cash generation
grapesjs.init({container: 'body', autorender: 0});
grapesjs.init({container: 'body',autorender: 0, storageManager: {
autoload: 0,
type:'none'
},});
window.$ = Backbone.$;
Object.keys(window).forEach((key) => {

2
test/main.js

@ -16,7 +16,6 @@ describe('Main', () => {
require(`${path}css_composer`);
require(`${path}device_manager`);
require(`${path}dom_components`);
require(`${path}grapesjs`);
require(`${path}modal`);
require(`${path}panels`);
require(`${path}parser`);
@ -25,4 +24,5 @@ describe('Main', () => {
require(`${path}storage_manager`);
require(`${path}style_manager`);
require(`${path}trait_manager`);
require(`${path}grapesjs`);
});

15
test/specs/grapesjs/index.js

@ -2,7 +2,7 @@ const PluginManager = require('plugin_manager');
describe('GrapesJS', () => {
describe('Main', () => {
describe.skip('Main', () => {
var obj;
var fixtures;
@ -26,7 +26,6 @@ describe('GrapesJS', () => {
before(() => {
editorName = 'editor-fixture';
fixtures = $("#fixtures");
});
beforeEach(() => {
@ -41,14 +40,16 @@ describe('GrapesJS', () => {
},
}
obj = grapesjs;
fixture = $('<div id="' + editorName + '"></div>');
fixture.empty().appendTo(fixtures);
//fixture = $('<div id="' + editorName + '"></div>');
//fixture.empty().appendTo(fixtures);
document.body.innerHTML = `<div id="fixtures"><div id="${editorName}"></div></div>`;
fixtures = document.body.querySelector('#fixtures');
});
afterEach(() => {
config = {};
obj = null;
fixture.remove();
});
it('Main object should be loaded', () => {
@ -59,7 +60,7 @@ describe('GrapesJS', () => {
var editor = obj.init(config);
expect(editor).toExist();
});
it('Init new editor with node for container', () => {
var configAlt = {
container: document.createElement('div'),
@ -101,7 +102,7 @@ describe('GrapesJS', () => {
it.skip('Init editor from element', () => {
config.fromElement = 1;
fixture.html(documentEl);
fixtures.innerHTML = documentEl;
var editor = obj.init(config);
var html = editor.getHtml();
var css = editor.getCss();

17
test/specs/modal/view/ModalView.js

@ -3,26 +3,19 @@ const Modal = require('modal_dialog/model/Modal');
module.exports = {
run() {
describe('ModalView', () => {
describe.only('ModalView', () => {
var $fixtures;
var $fixture;
var model;
var view;
var editorModel;
before(() => {
$fixtures = $("#fixtures");
$fixture= $('<div class="modal-fixture"></div>');
});
beforeEach(() => {
model = new Modal();
view = new ModalView({
model
});
$fixture.empty().appendTo($fixtures);
$fixture.html(view.render().el);
document.body.innerHTML = '<div id="fixtures"></div>';
document.body.querySelector('#fixtures').appendChild(view.render().el);
});
afterEach(() => {
@ -30,10 +23,6 @@ module.exports = {
model = null;
});
after(() => {
$fixture.remove();
});
it("The content is not empty", () => {
expect(view.el.innerHTML).toExist();
});

5
test/specs/selector_manager/index.js

@ -80,6 +80,9 @@ describe('SelectorManager', () => {
Models.run();
ClassTagView.run();
ClassTagsView.run();
e2e.run();
describe.skip('E2E', () => {
e2e.run();
});
});

8
webpack.config.js

@ -15,7 +15,10 @@ if(env !== 'dev') {
]
}
plugins.push(new webpack.ProvidePlugin({_: 'underscore'}));
plugins.push(new webpack.ProvidePlugin({
_: 'underscore',
Backbone: 'backbone'
}));
module.exports = {
entry: './src',
@ -27,6 +30,9 @@ module.exports = {
plugins: plugins,
module: {
loaders: [{
test: /backbone\.js$/,
use: ['imports-loader?define=>false']
},{
test: /grapesjs\/index\.js$/,
loader: 'string-replace-loader',
query: {

11
yarn.lock

@ -1252,6 +1252,10 @@ caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
cash-dom@^1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/cash-dom/-/cash-dom-1.3.5.tgz#f58698933561217bf408b5c3f5fb60aaba866e20"
ccount@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.0.2.tgz#53b6a2f815bb77b9c2871f7b9a72c3a25f1d8e89"
@ -2926,6 +2930,13 @@ ignore@^3.3.3:
version "3.3.5"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.5.tgz#c4e715455f6073a8d7e5dae72d2fc9d71663dba6"
imports-loader@^0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/imports-loader/-/imports-loader-0.7.1.tgz#f204b5f34702a32c1db7d48d89d5e867a0441253"
dependencies:
loader-utils "^1.0.2"
source-map "^0.5.6"
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"

Loading…
Cancel
Save