mirror of https://github.com/artf/grapesjs.git
3 changed files with 28 additions and 10 deletions
@ -1,6 +1,19 @@ |
|||||
import { Collection } from '../../common'; |
import { isArray, isString } from 'underscore'; |
||||
import Category from './Category'; |
import { AddOptions, Collection } from '../../common'; |
||||
|
import { normalizeKey } from '../../utils/mixins'; |
||||
|
import Category, { BlockCategoryProperties } from './Category'; |
||||
|
|
||||
export default class Categories extends Collection<Category> {} |
export default class Categories extends Collection<Category> { |
||||
|
/** @ts-ignore */ |
||||
|
add(model: (BlockCategoryProperties | Category)[] | BlockCategoryProperties | Category, opts?: AddOptions) { |
||||
|
const models = isArray(model) ? model : [model]; |
||||
|
models.forEach(md => md && (md.id = normalizeKey(`${md.id}`))); |
||||
|
return super.add(model, opts); |
||||
|
} |
||||
|
|
||||
|
get(id: string | Category) { |
||||
|
return super.get(isString(id) ? normalizeKey(id) : id); |
||||
|
} |
||||
|
} |
||||
|
|
||||
Categories.prototype.model = Category; |
Categories.prototype.model = Category; |
||||
|
|||||
Loading…
Reference in new issue