mirror of https://github.com/artf/grapesjs.git
1 changed files with 11 additions and 4 deletions
@ -1,21 +1,28 @@ |
|||||
import { Collection } from '../../common'; |
import { Collection } from '../../common'; |
||||
|
import EditorModel from '../../editor/model/Editor'; |
||||
import Sector from './Sector'; |
import Sector from './Sector'; |
||||
|
|
||||
export default class Sectors extends Collection { |
export default class Sectors extends Collection<Sector> { |
||||
initialize(prop, opts = {}) { |
em!: EditorModel; |
||||
|
module!: any; |
||||
|
|
||||
|
initialize(prop: any, opts: { em?: EditorModel; module?: any } = {}) { |
||||
const { module, em } = opts; |
const { module, em } = opts; |
||||
this.em = em; |
this.em = em!; |
||||
this.module = module; |
this.module = module; |
||||
this.listenTo(this, 'reset', this.onReset); |
this.listenTo(this, 'reset', this.onReset); |
||||
} |
} |
||||
|
|
||||
|
// @ts-ignore
|
||||
model(props, opts = {}) { |
model(props, opts = {}) { |
||||
|
// @ts-ignore
|
||||
const { em } = opts.collection; |
const { em } = opts.collection; |
||||
return new Sector(props, { ...opts, em }); |
return new Sector(props, { ...opts, em }); |
||||
} |
} |
||||
|
|
||||
onReset(models, opts = {}) { |
onReset(models: any, opts: { previousModels?: Sector[] } = {}) { |
||||
const prev = opts.previousModels || []; |
const prev = opts.previousModels || []; |
||||
|
// @ts-ignore
|
||||
prev.forEach(sect => sect.get('properties').reset()); |
prev.forEach(sect => sect.get('properties').reset()); |
||||
} |
} |
||||
} |
} |
||||
Loading…
Reference in new issue