diff --git a/docs/modules/Components.md b/docs/modules/Components.md index 36d62de51..8d7779d40 100644 --- a/docs/modules/Components.md +++ b/docs/modules/Components.md @@ -13,25 +13,6 @@ This guide is referring to GrapesJS v0.14.67 or higher [[toc]] -## Built-in components -The list of built-in components, ordered by their position in the Component Type Stack -* default (Basic) -* wrapper -* text -* textnode -* svg -* script -* image -* video -* label -* link -* map -* table -* row (for the table) -* cell (for the table) - - - ## How Components work? Let's see in detail how components work by looking at all steps from adding an HTML string to the editor. @@ -95,16 +76,18 @@ You can notice the result is similar to what is generally called a **Virtual DOM The meaning of properties like `tagName`, `attributes` and `components` are quite obvious, but what about `type`?! This particular property specifies the actual **Component** of our **Component Definition** (you check the list of default components [below](#built-in-components)) and if it's omitted, the default one will be used `type: 'default'`. At this point, a good question would be, how the editor assignes those types by starting from a simple HTML string? This step is identified as **Component Recognition** and it's explained in detail in the next paragraph. -### Component recognition +### Component Recognition and Component Type Stack -As we said before, when you pass an HTML string as a component to the editor, that string is parsed and compiled to the [Component Definition](#component-definition) with a new `type` property. To understand what `type` should be assigned, for each parsed HTML Element, the editor iterates over all the defined components, called **Component Type Stack**, and checks via `isComponent` method (we will see it later) if that component type is appropriate for that element. The Component Type Stack is a simple array of components but what is important is the order of those components. Any new added Custom Component (we'll see later how to create them) goes on top of the Component Type Stack and each element returned from the parser iterates the stack from top to bottom (the last element of the stack is the `default` one), the iteration stops once one of the component returns a truthy value from the `isComponent` method. +As we said before, when you pass an HTML string as a component to the editor, that string is parsed and compiled to the [Component Definition](#component-definition) with a new `type` property. To understand what `type` should be assigned, for each parsed HTML Element, the editor iterates over all the defined components, called **Component Type Stack**, and checks via `isComponent` method (we will see it later) if that component type is appropriate for that element. The Component Type Stack is just a simple array of components but the important part is the order of those components. Any new added Custom Component (we'll see later how to create them) goes on top of the Component Type Stack and each element returned from the parser iterates the stack from top to bottom (the last element of the stack is the `default` one), the iteration stops once one of the component returns a truthy value from the `isComponent` method. SVG - ComponentTypeStack +::: tip If you're importing big chunks of HTML code you might want to improve the performances by skipping the parsing and the component recognition steps by passing directly Component Definiton objects or using the JSX syntax. Read more about it here...TODO +::: -### Component creation +### Component Creation Once the **Component Definition** is ready and the type is assigned, the [Component](api/component.html) instance can be created (known also as the **Model**). Let's step back to our previous example with the HTML string, the result of the `append` method is an array of added components. @@ -156,7 +139,7 @@ The Component instance is responable for the **final data** (eg. HTML, JSON) of -### Component rendering +### Component Rendering Another important thing of components is how they are rendered in the **canvas**, this aspect is handled by the **View** of the component. It has nothing to do with the **final data**, you can return a big `