Migration guide for @uploadcare/blocks v0.25.0
BREAKING CHANGES
-
Configuration in CSS is now deprecated. Although it currently works, it will be removed shortly. In lieu of this, we are introducing a new lr-config block for configuration definitions.
-
The
css-srcattribute is now required on solution blocks. This implies that the use of Shadow DOM is enforced. -
The
ctx-nameattribute is required for each block on the page. -
Method
setUploadMetadatais deprecated in favour ofmetadataDOM property on thelr-configblock. -
Method
addFilesis deprecated in favour ofaddFileFromObject -
CloudEditor(lr-cloud-editor) solution block is renamed toCloudImageEditor(lr-cloud-image-editor). -
CloudImageEditor(lr-cloud-image-editor) activity is renamed toCloudImageEditorActivity(lr-cloud-image-editor-activity). -
All solution bundles are prefixed with
lr-prefix:
file-uploader-regular.min.js->lr-file-uploader-regular.min.jsfile-uploader-regular.min.css->lr-file-uploader-regular.min.cssfile-uploader-inline.min.js->lr-file-uploader-inline.min.jsfile-uploader-inline.min.css->lr-file-uploader-inline.min.cssfile-uploader-minimal.min.js->lr-file-uploader-minimal.min.jsfile-uploader-minimal.min.css->lr-file-uploader-minimal.min.css
- Solution bundles do not automatically register blocks. You will need to register them manually:
-
Bundle
blocks.iife.jsis renamed toblocks.iife.min.js. -
Bundle
blocks-browser.min.jsis deprecated. Useblocks.iife.min.jsinstead.
How to migrate
Configuration
First and foremost, you need to shift all the configuration from CSS to the lr-config block.
For instance, if you have the following CSS:
Get YOUR_PUBLIC_KEY from API keys.
Move it to the lr-config block:
Subsequently, you should link your solution block to the lr-config block using the ctx-name attribute:
The property names remain the same but without the --cfg prefix. For example,
--cfg-pubkey becomes simply pubkey.
See the configuration reference for more details.
Dynamic configuration updates
If you have dynamically updated CSS configuration like this:
You need to update it to the following:
Both attributes and DOM properties are reactive, so you don’t need to call
updateCtxCssData anymore.
Shadow DOM and css-src
Shadow DOM is now enforced for all the solution blocks. It means that you need
to use css-src attribute to attach CSS to the block.
If you previously attached CSS to the global like this:
You need to use css-src attribute instead:
(Other attributes are omitted for brevity)
ctx-name attribute
ctx-name attribute is required for all the blocks now, even if you have only
one block on the page. It’s used to wire blocks to the lr-config block. For
example:
(Other attributes are omitted for brevity)
Replace setUploadMetadata with metadata DOM property
If you were using setUploadMetadata method like this:
You need to replace it with metadata DOM property on the lr-config block:
See the configuration reference for more details.
Replace addFiles with addFileFromObject
If you were using addFiles method like this:
You need to replace it with addFileFromObject:
In case of multiple files, you need to call addFileFromObject for each file:
See the addFileFromObject reference for more details.
Rename CloudEditor -> CloudImageEditor
If you were using a standalone lr-cloud-editor solution block, you need to rename
it to lr-cloud-image-editor like this:
Rename CloudImageEditor -> CloudImageEditorActivity
If you were using lr-cloud-image-editor activity block inside your custom
Symbiote.js templates, you need to rename it to lr-cloud-image-editor-activity
like this:
Rename imported JS and CSS bundles
Just rename all the imports according to the following table:
For example:
Became:
Call registerBlocks manually
If you have installed blocks using min.js bundles, you need to call
registerBlocks manually:
Rename blocks.iife.js to blocks.iife.min.js
If you previously used the blocks.iife.js bundle, you need to rename it to
blocks.iife.min.js as follows:
Rename blocks-browser.min.js to blocks.iife.min.js
If you were using the connectBlocksFrom method in conjunction with the
blocks-browser.min.js bundle, you need to rename it to blocks.iife.min.js,
as shown below:
If you were using blocks-browser.min.js via a script tag with type="module",
you need to rename it to blocks.min.js, as shown below:
If you were using blocks-browser.min.js via a script tag without
type="module", you need to rename it to blocks.iife.min.js, as shown below: