Browse Source

Use HTMLElement for container

pull/282/head
A---- 9 years ago
parent
commit
d71882c196
  1. 9
      src/grapesjs/index.js
  2. 12
      test/specs/grapesjs/index.js

9
src/grapesjs/index.js

@ -18,7 +18,7 @@ module.exports = (config => {
/**
* Initializes an editor based on passed options
* @param {Object} config Configuration object
* @param {string} config.container Selector which indicates where render the editor
* @param {string|DomNode} config.container Selector which indicates where render the editor
* @param {Object|string} config.components='' HTML string or Component model in JSON format
* @param {Object|string} config.style='' CSS string or CSS model in JSON format
* @param {Boolean} [config.fromElement=false] If true, will fetch HTML and CSS from selected container
@ -52,7 +52,12 @@ module.exports = (config => {
throw new Error("'container' is required");
}
c.el = document.querySelector(els);
if (els instanceof window.HTMLElement) {
c.el = els;
}
else {
c.el = document.querySelector(els);
}
var editor = new Editor(c).init();
// Load plugins

12
test/specs/grapesjs/index.js

@ -60,6 +60,18 @@ describe('GrapesJS', () => {
expect(editor).toExist();
});
it('Init new editor with node for container', () => {
var configAlt = {
container: document.createElement('div'),
storageManager: {
autoload: 0,
type:'none'
},
}
var editor = obj.init(configAlt);
expect(editor).toExist();
});
it('New editor is empty', () => {
var editor = obj.init(config);
var html = editor.getHtml();

Loading…
Cancel
Save