|
|
|
@ -32,17 +32,19 @@ |
|
|
|
* * [add](#add) |
|
|
|
* * [get](#get) |
|
|
|
* * [getAll](#getall) |
|
|
|
* * [getAllWrappers](#getallwrappers) |
|
|
|
* * [getMain](#getmain) |
|
|
|
* * [remove](#remove) |
|
|
|
* * [select](#select) |
|
|
|
* * [getSelected](#getselected) |
|
|
|
* |
|
|
|
* [Page]: page.html |
|
|
|
* [Component]: component.html |
|
|
|
* |
|
|
|
* @module Pages |
|
|
|
*/ |
|
|
|
|
|
|
|
import { isString, bindAll } from 'underscore'; |
|
|
|
import { isString, bindAll, unique, flatten } from 'underscore'; |
|
|
|
import { createId } from 'utils/mixins'; |
|
|
|
import { Model } from 'backbone'; |
|
|
|
import Pages from './model/Pages'; |
|
|
|
@ -216,6 +218,25 @@ export default () => { |
|
|
|
return this.pages.models; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* Get wrapper components (aka body) from all pages and frames. |
|
|
|
* @returns {Array<[Component]>} |
|
|
|
* @example |
|
|
|
* // Get all the `image` components from the project
|
|
|
|
* const wrappers = pageManager.getAllWrappers(); |
|
|
|
* const allImages = wrappers.map(wrp => wrp.findType('image')).flat(); |
|
|
|
*/ |
|
|
|
getAllWrappers() { |
|
|
|
const pages = this.getAll(); |
|
|
|
return unique( |
|
|
|
flatten( |
|
|
|
pages.map(page => |
|
|
|
page.getAllFrames().map(frame => frame.getComponent()) |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
}, |
|
|
|
|
|
|
|
getAllMap() { |
|
|
|
return this.getAll().reduce((acc, i) => { |
|
|
|
acc[i.get('id')] = i; |
|
|
|
|