Skip to content

Commit 3335856

Browse files
committed
MC-2294: Architectural Review for MC-2294
- Upaded docs
1 parent 340b7a9 commit 3335856

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

app/code/Magento/PageBuilder/docs/image-uploader.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@ Use `additional_data` in your `<YourModule>/view/base/pagebuilder/content_type/<
107107

108108
To update the `<YourModule>/view/adminhtml/web/js/content-type/<content_type_name>/preview.js` file:
109109

110-
1. Add the uploader component, 'Magento_PageBuilder/js/content-type/uploader', dependency:
110+
1. Import the `Magento_PageBuilder/js/content-type/uploader` component as dependency.
111+
112+
For example:
111113

112114
``` js
113-
import Uploader from "../uploader";
115+
define(['Magento_PageBuilder/js/content-type/uploader'], function (Uploader) {
114116
```
115117
116118
**Constructor arguments**
@@ -125,6 +127,21 @@ import Uploader from "../uploader";
125127
| `onChangeCallback` | Function | A callback that will be called when an image is selected. | false | The image will be saved to the provided `dataStore` using `uploaderConfig.dataScope` as the key. |
126128
| `onDeleteCallback` | Function | A callback that will be called when the current used image is deleted from storage. | false | The image will be removed from to the provided `dataStore` using `uploaderConfig.dataScope` as the key. |
127129
130+
An example extracted from the image content type:
131+
132+
```js
133+
var dataStore = this.parent.dataStore.get();
134+
var initialImageValue = dataStore[this.config.additional_data.uploaderConfig.dataScope] || "";
135+
136+
this.uploader = new Uploader(
137+
'imageuploader_' + this.parent.id,
138+
this.config.additional_data.uploaderConfig,
139+
this.parent.id,
140+
this.parent.dataStore,
141+
initialImageValue,
142+
);
143+
```
144+
128145
2. Add configuration for the uploader in the `<content-type-name>.xml` file to initialize the uploader.
129146
130147
3. Register the listener to specify when the image is loaded from the uploader UI component:

0 commit comments

Comments
 (0)