@ -250,6 +250,9 @@ With this code the editor will be able to understand simple text `<input>`s, ass
To understand better how Traits work you should read its [dedicated page](Traits.html) but we highly sugggest to read it after you've finished reading this one
:::
### isComponent
Let's see in detail what we have done so far. The first thing to notice is the `isComponent` function, we have mentioned it already in [this](#component-recognition-and-component-type-stack) section and we need it to make the editor understand `<input>` during the component recognition step.
It receives only the `el` argument, which is the parsed HTMLElement node and expects a truthy value in case the element satisfies your logic condition. So, if we add this HTML string as component
One more tip, if you define a component type without the `isComponent`, the only way for the editor to see that component will be with a declared type (via object like `{ type: '...' }` or using `data-gjs-type`)
### Model
Now that we got how `isComponent` works we can start to explore the `model` property.
The `model` is probably the one you'll use the most as is what is used for the description of your component and the first thing you can see is its `defaults` key which just stands for *default component properties* and it reflects the already described [Component Definition](#component-definition)
The model defines also what you will see as the resultant HTML (the export code) and you've probably noticed the use of `tagName` (if not specified the `div` will be used) and `attributes` properties on the model.
One another important property (not used because `<input/>` doesn't need it) might be `components`, which defines default internal components
```js
defaults: {
tagName: 'div',
attributes: { title: 'Hello' },
// Can be a string
components: `
<h1>Header test</h1>
<p>Paragraph test</p>
`,
// A component definiton
components: {
tagName: 'h1',
components: 'Header test',
},
// Array of strings/component definitons
components: [
{
tagName: 'h1',
components: 'Header test',
},
'<p>Paragraph test</p>',
],
// Or a function, which get as an argument the current
// model and expects as the return one of the possible