|
|
@ -1,5 +1,6 @@ |
|
|
import { forEach, result } from 'underscore'; |
|
|
import { forEach, result } from 'underscore'; |
|
|
import { PageManagerConfig } from '../types'; |
|
|
import { PageManagerConfig } from '../types'; |
|
|
|
|
|
import type { FrameProperties } from '../../canvas/model/Frame'; |
|
|
import Frames from '../../canvas/model/Frames'; |
|
|
import Frames from '../../canvas/model/Frames'; |
|
|
import { Model } from '../../common'; |
|
|
import { Model } from '../../common'; |
|
|
import ComponentWrapper from '../../dom_components/model/ComponentWrapper'; |
|
|
import ComponentWrapper from '../../dom_components/model/ComponentWrapper'; |
|
|
@ -29,10 +30,20 @@ export interface PageProperties { |
|
|
*/ |
|
|
*/ |
|
|
styles?: string | CssRuleJSON[]; |
|
|
styles?: string | CssRuleJSON[]; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Frames to load with the page. |
|
|
|
|
|
*/ |
|
|
|
|
|
frames?: FrameProperties[]; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Skip page from project storage. |
|
|
|
|
|
*/ |
|
|
|
|
|
skipFromStorage?: boolean; |
|
|
|
|
|
|
|
|
[key: string]: unknown; |
|
|
[key: string]: unknown; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export interface PagePropertiesDefined extends Pick<PageProperties, 'id' | 'name'> { |
|
|
export interface PagePropertiesDefined extends Pick<PageProperties, 'id' | 'name' | 'skipFromStorage'> { |
|
|
frames: Frames; |
|
|
frames: Frames; |
|
|
[key: string]: unknown; |
|
|
[key: string]: unknown; |
|
|
} |
|
|
} |
|
|
@ -47,17 +58,17 @@ export default class Page extends Model<PagePropertiesDefined> { |
|
|
} |
|
|
} |
|
|
em: EditorModel; |
|
|
em: EditorModel; |
|
|
|
|
|
|
|
|
constructor(props: any, opts: { em?: EditorModel; config?: PageManagerConfig } = {}) { |
|
|
constructor(props: PageProperties, opts: { em?: EditorModel; config?: PageManagerConfig } = {}) { |
|
|
super(props, opts); |
|
|
super(props as any, opts); |
|
|
const { em } = opts; |
|
|
const { em } = opts; |
|
|
const defFrame: any = {}; |
|
|
const defFrame: FrameProperties = {}; |
|
|
this.em = em!; |
|
|
this.em = em!; |
|
|
if (!props.frames) { |
|
|
if (!props.frames) { |
|
|
defFrame.component = props.component; |
|
|
defFrame.component = props.component; |
|
|
defFrame.styles = props.styles; |
|
|
defFrame.styles = props.styles; |
|
|
['component', 'styles'].map((i) => this.unset(i)); |
|
|
['component', 'styles'].map((i) => this.unset(i)); |
|
|
} |
|
|
} |
|
|
const frms: any[] = props.frames || [defFrame]; |
|
|
const frms: FrameProperties[] = props.frames || [defFrame]; |
|
|
const frames = new Frames(em!.Canvas, frms); |
|
|
const frames = new Frames(em!.Canvas, frms); |
|
|
frames.page = this; |
|
|
frames.page = this; |
|
|
this.set('frames', frames); |
|
|
this.set('frames', frames); |
|
|
@ -135,6 +146,8 @@ export default class Page extends Model<PagePropertiesDefined> { |
|
|
const obj = Model.prototype.toJSON.call(this, opts); |
|
|
const obj = Model.prototype.toJSON.call(this, opts); |
|
|
const defaults = result(this, 'defaults'); |
|
|
const defaults = result(this, 'defaults'); |
|
|
|
|
|
|
|
|
|
|
|
delete obj.skipFromStorage; |
|
|
|
|
|
|
|
|
// Remove private keys
|
|
|
// Remove private keys
|
|
|
forEach(obj, (value, key) => { |
|
|
forEach(obj, (value, key) => { |
|
|
key.indexOf('_') === 0 && delete obj[key]; |
|
|
key.indexOf('_') === 0 && delete obj[key]; |
|
|
|