Add-on UI SDK Reference
Overview
This reference is provided to outline the interfaces, methods, properties and events that support the add-on UI SDK features. It begins with an introduction to the core addOnUiSdk module, which provides access to all of the interfaces available to use in the iframe where your add-on is running. Import this module to use it for accessing all of the API's that allow you to implement features like those outlined in the next section.
Features Supported by the SDK
- Importing Content
- Exporting Content
- Accessing Content
- Drag & Drop Behavior
- Authorization with OAuth 2.0
- Client-side Storage Access
- Modal Dialogs
- Locale Detection
- Theme Detection
- Access to the Manifest
- Access to the Document information
data-slots=text
data-variant=success
data-slots=header, text1, text2, text3, text4
data-variant=success
SDK vs API
Note: an interface can also be considered an object in terms of this reference. You can traverse the addOnUISdk interfaces/objects (ie: app,instance) etc in the left navigation to learn more.
Importing the addOnUISdk for Use
The add-on SDK is available as a hosted JavaScript module on the Adobe CDN. It's referenced with an import statement in either an HTML <script> tag or in the list of import statements in the JavaScript source. However, you don't need to worry about adding this reference if you used the CLI to create your add-on project, since it will already be imported for you, and the location it was placed will depend on the template you chose. The following sections show how it's imported into different file types for reference.
Import into HTML file
To use the SDK from an HTML file, simply include a link to it in a <script> tag with the type=module attribute on it to ensure everything is initialized properly.
<body>
Hello World!
<script type="module">
import addOnUISdk from "https://express.adobe.com/static/add-on-sdk/sdk.js";
addOnUISdk.ready.then(async () => {
console.log("addOnUISdk is ready for use.");
});
</script>
</body>
data-slots=text
data-variant=success
<script> tag just before the closing <body> tag helps reduce the page loading time.Import into JavaScript/TypeScript file
The SDK can be referenced in .js/.jsx/.ts/.tsx source files by adding it to the list of imports as a default module reference, such as in the following:
import addOnUISdk from "https://express.adobe.com/static/add-on-sdk/sdk.js";
Note: if you created your add-on project with the CLI based on the typescript or typescript-react templates, you will automatically get a types definition file named add-on-ui-sdk.d.ts generated in your project src for you. This file contains the following exports, and allows you to take advantage of type checking and auto-completion features while developing with the Add-on SDK in your IDE.
declare module "https://express.adobe.com/static/add-on-sdk/sdk.js" {
export * from "@adobe-ccwebext/ccweb-add-on-sdk-types";
export { default } from "@adobe-ccwebext/ccweb-add-on-sdk-types";
}
See the typescript definitions section in the developer guides as well for more details.
addOnUISdk Properties
The following properties can be accessed from the addOnUISdk object after it has been imported.<br/><br/>
readonlyaddOnUISdk.appobjectreadonlyaddOnUISdk.instanceobjectreadonlyaddOnUISdk.readyPromiseaddOnUISdk.constantsobjectreadonlyaddOnUISdk.apiVersionstringaddOnUISdk Errors
The table below describes the possible error messages that may occur when using the core addOnUISdk object, with a description of the scenario that will return them.
<br/>
${propertyName} property. SDK is not fully initialized.${apiVersion}