@@ -12,13 +12,16 @@ If you have an empty CMS instance, and you want to see how it all
12
12
works go to your CMS (SaaS) instance and:
13
13
14
14
1 . Go to ** Settings** > ** Content Types** .
15
- 2 . Click ** Create New** and select ** Element Type** from the drop-down list.
15
+ 2 . Click ** Create New** and select ** Block Type** from the drop-down list.
16
16
3 . Enter _ ParagraphElement_ for the ** Name** and ** Display name** fields.
17
17
4 . Click ** Create** .
18
18
5 . Click ** Add Property** and select ** Text** from the drop-down list.
19
19
6 . Enter _ Text_ for the ** Name** in the ** Configure Property** page.
20
20
7 . Click on the ** Text Type** drop-down menu and select ** XHTML string (>255)** .
21
21
8 . Click ** Save** .
22
+ 8 . Go to ** Setting**
23
+ 9 . Tick checkboxes ** Available for composition in Visual Builder** and ** Display as Element**
24
+ 10 . Click ** Save** .
22
25
23
26
Then in order to run the sample you need to do the following:
24
27
@@ -110,21 +113,24 @@ We now need to add a new script to package.json
110
113
111
114
This script will generate types based your graphql schema.
112
115
113
- ### Adding element type
116
+ ### Adding element
114
117
115
- Before we run the codegen let's add a simple Element type to our SaaS CMS instance.
118
+ Before we run the codegen let's add a simple Element to our SaaS CMS instance.
116
119
Please open ` Settings ` and ` Content types ` screen.
117
120
118
- Click on ` Create New... ` menu item and choose ` Element type` option.
119
- ![ clicking add element type] ( docs/contenttype_add_elementtype .png )
121
+ Click on ` Create New... ` menu item and choose ` Block type` option.
122
+ ![ clicking add element type] ( docs/contenttype_add_block .png )
120
123
121
124
Fill in the name and display name and hit the ` Create ` button.
122
- ![ adding element name] ( docs/contenttype_add_elementtype_dialog .png )
125
+ ![ adding element name] ( docs/contenttype_add_block_dialog .png )
123
126
124
127
You will see an empty list of properties, hit the ` Add property ` button and add a single ` Text ` ` XHTML string ` property:
125
128
![ adding property] ( docs/contenttype_add_property.png )
126
129
127
- After that you should see the newly created element type in the list.
130
+ After that click on ` Settings ` and tick ` Available for composition in Visual Builder ` and ` Display as Element ` checkboxes
131
+ ![ display as element] ( docs/block_settings_display_as.png )
132
+
133
+ You should see the newly created element type in the list.
128
134
![ added element type] ( docs/contenttype_list.png )
129
135
130
136
### Graphql generation
@@ -201,7 +207,7 @@ query VisualBuilder($key: String, $version: String) {
201
207
... on CompositionStructureNode {
202
208
key
203
209
elements: nodes {
204
- ...compositionElementNode
210
+ ...compositionComponentNode
205
211
}
206
212
}
207
213
}
@@ -265,7 +271,7 @@ const VisualBuilderComponent: FC<VisualBuilderProps> = ({ key, version }) => {
265
271
<div className = " flex-1 flex flex-col flex-nowrap justify-start vb:col" key = { column .key } >
266
272
{ column .elements ?.map ((element : any ) =>
267
273
<div data-epi-block-id = { element ?.key } key = { element ?.key } >
268
- <CompositionNodeComponent compositionElementNode = { element } />
274
+ <CompositionNodeComponent compositionComponentNode = { element } />
269
275
</div >
270
276
)}
271
277
</div >
@@ -292,10 +298,10 @@ import { FragmentType, useFragment } from '../../graphql/fragment-masking'
292
298
import { graphql } from ' @/graphql'
293
299
import ParagraphElementComponent from ' ../elements/ParagraphElementComponent'
294
300
295
- export const CompositionElementNodeFragment = graphql (/* GraphQL */ `
296
- fragment compositionElementNode on CompositionElementNode {
301
+ export const CompositionComponentNodeFragment = graphql (/* GraphQL */ `
302
+ fragment compositionComponentNode on CompositionComponentNode {
297
303
key
298
- element {
304
+ component {
299
305
_metadata {
300
306
types
301
307
}
@@ -304,23 +310,23 @@ export const CompositionElementNodeFragment = graphql(/* GraphQL */ `
304
310
}
305
311
` )
306
312
307
- const CompositionElementNodeComponent = (props : {
308
- compositionElementNode : FragmentType <typeof CompositionElementNodeFragment >
313
+ const CompositionComponentNodeComponent = (props : {
314
+ compositionComponentNode : FragmentType <typeof CompositionComponentNodeFragment >
309
315
}) => {
310
- const compositionElementNode = useFragment (CompositionElementNodeFragment , props .compositionElementNode )
311
- const element = compositionElementNode . element
312
- switch (element ?.__typename ) {
316
+ const compositionComponentNode = useFragment (CompositionComponentNodeFragment , props .compositionComponentNode )
317
+ const component = compositionComponentNode . component
318
+ switch (component ?.__typename ) {
313
319
case " ParagraphElement" :
314
- return <ParagraphElementComponent paragraphElement = { element } />
320
+ return <ParagraphElementComponent paragraphElement = { component } />
315
321
default :
316
322
return <>NotImplementedException</>
317
323
}
318
324
}
319
325
320
- export default CompositionElementNodeComponent
326
+ export default CompositionComponentNodeComponent
321
327
```
322
328
323
- As you can see based on ` element .__typename` we can use different components - in our
329
+ As you can see based on ` component .__typename` we can use different components - in our
324
330
example we will use ` ParagraphElementComponent ` .
325
331
326
332
### Subscribing to content changes
0 commit comments