Browse Source

Change frame components prop

pull/3411/head
Artur Arseniev 5 years ago
parent
commit
bfad59dcf8
  1. 2
      src/canvas/model/Canvas.js
  2. 14
      src/canvas/model/Frame.js
  3. 6
      test/specs/pages/index.js

2
src/canvas/model/Canvas.js

@ -28,7 +28,7 @@ export default Backbone.Model.extend({
const frame = const frame =
mainPage.getMainFrame() || mainPage.getMainFrame() ||
frames.add({ frames.add({
components: em.getWrapper(), component: em.getWrapper(),
styles: em.getStyle() styles: em.getStyle()
}); });
styles.forEach(style => frame.addLink(style)); styles.forEach(style => frame.addLink(style));

14
src/canvas/model/Frame.js

@ -13,25 +13,25 @@ export default Model.extend({
width: null, width: null,
height: null, height: null,
head: [], head: [],
components: '', component: '',
styles: '' styles: ''
}), }),
initialize(props, opts = {}) { initialize(props, opts = {}) {
const { config } = opts; const { config } = opts;
const { em } = config; const { em } = config;
const { styles, components } = this.attributes; const { styles, component } = this.attributes;
const domc = em.get('DomComponents'); const domc = em.get('DomComponents');
const conf = domc.getConfig(); const conf = domc.getConfig();
const allRules = em.get('CssComposer').getAll(); const allRules = em.get('CssComposer').getAll();
this.em = em; this.em = em;
const modOpts = { em, config: conf, frame: this }; const modOpts = { em, config: conf, frame: this };
if (!isComponent(components)) { if (!isComponent(component)) {
const wrp = isObject(components) ? components : { components }; const wrp = isObject(component) ? component : { components: component };
wrp.type = 'wrapper'; !wrp.type && (wrp.type = 'wrapper');
const Wrapper = domc.getType('wrapper').model; const Wrapper = domc.getType('wrapper').model;
this.set('components', new Wrapper(wrp, modOpts)); this.set('component', new Wrapper(wrp, modOpts));
} }
if (!styles) { if (!styles) {
@ -46,7 +46,7 @@ export default Model.extend({
}, },
getComponent() { getComponent() {
return this.get('components'); return this.get('component');
}, },
getStyles() { getStyles() {

6
test/specs/pages/index.js

@ -95,7 +95,7 @@ describe('Pages', () => {
id: idPage1, id: idPage1,
frames: [ frames: [
{ {
components: [comp1], component: [comp1],
styles: `#${idComp1} { color: red }` styles: `#${idComp1} { color: red }`
} }
] ]
@ -104,7 +104,7 @@ describe('Pages', () => {
id: 'page-2', id: 'page-2',
frames: [ frames: [
{ {
components: [comp2], component: [comp2],
styles: `#${idComp2} { color: blue }` styles: `#${idComp2} { color: blue }`
} }
] ]
@ -113,7 +113,7 @@ describe('Pages', () => {
id: 'page-3', id: 'page-3',
frames: [ frames: [
{ {
components: '<div id="comp3">Component 3</div>', component: '<div id="comp3">Component 3</div>',
styles: `#comp3 { color: green }` styles: `#comp3 { color: green }`
} }
] ]

Loading…
Cancel
Save