Browse Source

`editor.addComponents` now returns always an array components

refactor-traits
Artur Arseniev 7 years ago
parent
commit
a903924211
  1. 9
      docs/modules/Components.md
  2. 4
      src/editor/index.js

9
docs/modules/Components.md

@ -106,7 +106,14 @@ If you're importing big chunks of HTML code you might want to improve the perfor
### Component creation and rendering
Once the **Component Definition**
Once the **Component Definition** is ready and the type is assigned, the Component intance can be created. Let's step back to our previous example with the HTML string, the result of the `append` method is an array of added components.
```js
const component = editor.addComponents(`<div>
<img src="https://path/image" />
<span title="foo">Hello world!!!</span>
</div>`)[0];
```
--- OLD

4
src/editor/index.js

@ -337,7 +337,7 @@ export default (config = {}) => {
* @param {Boolean} [opts.avoidUpdateStyle=false] If the HTML string contains styles,
* by default, they will be created and, if already exist, updated. When this option
* is true, styles already created will not be updated.
* @return {Model|Array<Model>}
* @return {Array<Component>}
* @example
* editor.addComponents('<div class="cls">New component</div>');
* // or
@ -348,7 +348,7 @@ export default (config = {}) => {
* });
*/
addComponents(components, opts) {
return this.getComponents().add(components, opts);
return this.getWrapper().append(components, opts);
},
/**

Loading…
Cancel
Save