You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/create-basic-content-type/overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ After registering your module (`bin/magento setup:upgrade`) you will be ready to
28
28
29
29
The steps for creating the Quote content type are illustrated and described below. The reality is not quite this linear, but these steps do represent the basic phases and flow for building new Page Builder content types.
1.**Add configuration**: Create an XML file to define your content type and reference the other files that control the appearance and behavior of your content type.
34
34
2.**Add templates**: Create HTML templates that define the appearance of your content types on the Admin stage (`preview.html`) and the storefront (`master.html`).
This document outlines how to implement the inline editing toolbar for any content type. This feature is used within the heading to allow for easy modification of the heading type and alignment. It can be used within your content types to quickly change common things without needing to open the full editor.
3
+
This topic shows you how to implement an inline toolbar for your content type. You can see an example of a toolbar in Page Builder's Heading content type, as shown here:
6
4
7
5

8
6
9
-
## Overview
10
-
11
-
To add a custom toolbar to a Page Builder content block:
7
+
Toolbars provide end-users with a quick way to change common properties of your content type (such as text alignment and heading types) without needing to open the full editor. The toolbar does not replace the need for form fields in the editor; it simply extends those fields.
12
8
13
-
1.[Add a toolbar configuration](#toolbarConfig)
14
-
2.[Add a toolbar template](#toolbarTpl)
9
+
## How the Toolbar works
15
10
16
-
## Add a toolbar configuration {#toolbarConfig}
11
+
The diagram below shows the basic steps for adding a toolbar to your content type. It also shows how the various parts connect and work together.
17
12
18
-
To add a Toolbar configuration to your content block, you need to create a new instance of the `Toolbar` class, then add configuration options to it.
13
+
{:width="851px" height="auto"}
19
14
20
-
An example implementation can be found in the Heading content block:
In the Heading example, the `Toolbar` constructor requires its parent preview and the toolbar options you want to include as follows:
24
16
25
-
```javascript
26
-
newToolbar(this, this.getToolbarOptions());
27
-
```
17
+
## Step 1: Add toolbar options
28
18
29
-
where `this.getToolbarOptions()`returns the toolbar options. For example, the Heading toolbar's three text-alignment options are defined as follows:
19
+
Toolbar options are the clickable items in a toolbar that represent the property values of a form field. For example, the Heading content type adds toolbar options for the `text_align` field from `pagebuilder_base_form.xml`. The Heading adds the values of the `text_align` field (`left`, `center`, and `right`) as items on the toolbar, represented with the images provided by the icon CSS classes as shown here:
30
20
31
-
```typescript
21
+
```js
32
22
{
33
23
key:"text_align",
34
24
type:"select",
@@ -52,28 +42,79 @@ where `this.getToolbarOptions()`returns the toolbar options. For example, the He
52
42
},
53
43
```
54
44
55
-
Option property descriptions:
45
+
The `OptionInterface` and `ValueInterface` define the structure of toolbar options. You can find these interfaces in `magento2-page-builder/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type-toolbar.types.ts`. Descriptions of the elements follow:
|`key`| The field `name` you are binding to. For example: `<field name="quote_css"...>`|
50
+
|`type`| The `formElement` of the key field. For example: `<field ... formElement="select">`|
51
+
|`values`| Array of field option values. |
52
+
|`value`| Field option value, such as a CSS class (as shown in the code example). |
53
+
|`label`| Field option label, such as a label for a select option (as shown in the code example) |
54
+
|`icon`| CSS class name for the icon to display in the toolbar to represent the field's option. If you don't include a CSS class, the toolbar will display the label instead. |
-**Call the toolbar constructor.** The `Toolbar` constructor requires you to pass your `Preview` component and the array of toolbar options you created in step 1 (`this.toolbar = new Toolbar(this, this.getToolbarOptions());`). You can find Page Builder's `Toolbar` class in `magento2-page-builder/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type-toolbar.ts`.
Within your `preview.html` template, use a `div` element (with CSS class and events) to wrap whichever element in your template you want the toolbar to act on. For example, the custom Quote content type wraps its `<blockquote>` element within a `div` with the toolbar's CSS class and event binding, as shown here:
0 commit comments