From a903924211fa05f9174bed5ecf78f18ea7e87b63 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Mon, 22 Jul 2019 08:28:08 +0200 Subject: [PATCH] `editor.addComponents` now returns always an array components --- docs/modules/Components.md | 9 ++++++++- src/editor/index.js | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/modules/Components.md b/docs/modules/Components.md index 3dcadd895..dad7cabe4 100644 --- a/docs/modules/Components.md +++ b/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(`
+ + Hello world!!! +
`)[0]; +``` --- OLD diff --git a/src/editor/index.js b/src/editor/index.js index fad6a444b..06378f0d8 100644 --- a/src/editor/index.js +++ b/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} + * @return {Array} * @example * editor.addComponents('
New component
'); * // or @@ -348,7 +348,7 @@ export default (config = {}) => { * }); */ addComponents(components, opts) { - return this.getComponents().add(components, opts); + return this.getWrapper().append(components, opts); }, /**