MCPcopy
hub / github.com/GrapesJS/grapesjs / add

Method add

packages/core/src/abstract/ModuleCollection.ts:14–21  ·  view source on GitHub ↗
(model?: unknown, options?: AddOptions)

Source from the content-addressed store, hash-verified

12 add(model: Array<Record<string, any>> | TModel, options?: AddOptions): TModel;
13 add(models: Array<Array<Record<string, any>> | TModel>, options?: AddOptions): TModel[];
14 add(model?: unknown, options?: AddOptions): any {
15 //Note: the undefined case needed because backbonejs not handle the reset() correctly
16 var models = isArray(model) ? model : !isUndefined(model) ? [model] : undefined;
17
18 models = models?.map((m) => (m instanceof this.newModel ? m : new this.newModel(this.module, m))) ?? [undefined];
19
20 return super.add(isArray(model) ? models : models[0], options);
21 }
22
23 constructor(
24 module: ModuleExt<TModel>,

Callers

nothing calls this directly

Calls 1

isUndefinedFunction · 0.85

Tested by

no test coverage detected