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

Method components

packages/core/src/dom_components/model/Component.ts:1163–1175  ·  view source on GitHub ↗

* Set new collection if `components` are provided, otherwise the * current collection is returned * @param {Component|Component[]|String} [components] Component Definitions or HTML string * @param {Object} [opts={}] Options, same as in `Component.append()` * @returns {Collection|Array<[

(
    components?: T,
    opts: ResetComponentsOptions = {},
  )

Source from the content-addressed store, hash-verified

1161 * // -> 2
1162 */
1163 components<T extends ComponentAdd | undefined>(
1164 components?: T,
1165 opts: ResetComponentsOptions = {},
1166 ): undefined extends T ? Components : Component[] {
1167 const coll = this.get('components')!;
1168
1169 if (isUndefined(components)) {
1170 return coll as any;
1171 } else {
1172 coll.reset(undefined, opts);
1173 return (components ? this.append(components, opts) : []) as any;
1174 }
1175 }
1176
1177 /**
1178 * If exists, returns the child component at specific index.

Callers 15

syncOnComponentChangeMethod · 0.95
__postAddMethod · 0.95
__postRemoveMethod · 0.95
findTypeMethod · 0.95
containsMethod · 0.95
appendMethod · 0.95
getChildAtMethod · 0.95
getLastChildMethod · 0.95
emptyMethod · 0.95

Calls 4

appendMethod · 0.95
isUndefinedFunction · 0.85
getMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected