Skip to content

Commit

Permalink
Merge pull request #85 from AdobeDocs/abs72485/format-api
Browse files Browse the repository at this point in the history
Format API and supportedDeviceClass fix
  • Loading branch information
hollyschinsky authored Aug 5, 2024
2 parents 1b8f408 + 31dd0a0 commit 149d326
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 14 deletions.
18 changes: 13 additions & 5 deletions src/pages/guides/develop/use_cases/environment_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ addOnUISdk.app.on("themechange", (data) => {
});
```

## Detecting Locale and Supported Locales
## Detecting Locale, Supported Locales, and Format

If you want to find out the user's current locale, the list of supported locales, or detect when the locale changes (e.g., to set the language in your add-on), you can do so with the [`addOnUISdk.app.ui` object](/references/addonsdk/app-ui.md#locale) in the add-on SDK. A simple example is shown below.
If you want to find out the user's current locale, the list of supported locales, or detect when the locale changes (e.g., to set the language in your add-on), you can do so with the [`addOnUISdk.app.ui` object](/references/addonsdk/app-ui.md#locale) in the add-on SDK. Similarly, you can get and detect a change in the Format used display dates, times, numbers, etc. A simple example is shown below.

### Example

Expand All @@ -59,9 +59,17 @@ function setLanguage(language) {
addOnUISdk.ready.then(() => {
console.log(addOnUISdk.app.ui.locales);
setLanguage(addOnUISdk.app.ui.locale);
});

addOnUISdk.app.on("localechange", data => {
setLanguage(data.locale);
console.log(addOnUISdk.app.ui.format);

addOnUISdk.app.on("localechange", data => {
setLanguage(data.locale);
});

addOnUISdk.app.on("formatchange", data => {
console.log("New format", data.format);
});

});

```
57 changes: 53 additions & 4 deletions src/pages/references/addonsdk/app-ui.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# addOnUISdk.app.ui

Provides you with UI related values from the Adobe Express host application where the add-on is running, so you can do things such as detect the [current locale](../../guides/develop/use_cases/environment_settings.md#detecting-locale-and-supported-locales) or [theme](../../guides/develop/use_cases/environment_settings.md#detecting-theme) in use to update your add-on user interface accordingly.
Provides you with UI related values from the Adobe Express host application where the add-on is running, so you can do things such as detect the [current locale](../../guides/develop/use_cases/environment_settings.md#detecting-locale-supported-locales-and-format) or [theme](../../guides/develop/use_cases/environment_settings.md#detecting-theme) in use to update your add-on user interface accordingly.

## Properties

Expand Down Expand Up @@ -64,6 +64,34 @@ addOnUISdk.ready.then(async () => {
});
```

### format

Access the regional format currently set in Adobe Express to display dates, times, numbers, etc. This value is accessed via the `addOnUISdk.app.ui` object, so you should only access this object after the `addOnUISdk` is initialized (via the `addOnUISdk.ready`).

#### Values

A `string` containing the current format value. Current regional format could be one of:

```json
["ms-MY", "cs-CZ", "cy-GB", "da-DK", "de-DE", "de-LU", "de-AT", "de-CH", "et-EE",
"en-AU", "en-CA", "en-GB", "en-HK", "en-IN", "en-IE", "en-IL", "en-NZ", "en-SG",
"en-ZA", "en-US", "es-AR", "es-CL", "es-CO", "es-CR", "es-EC", "es-ES", "es-GT",
"es-419", "es-MX", "es-PE", "es-PR", "fr-BE", "fr-CA", "fr-FR", "fr-LU", "fr-CH",
"hr-HR", "id-ID", "it-IT", "it-CH", "lv-LV", "lt-LT", "hu-HU", "nl-BE", "nl-NL",
"nb-NO", "pl-PL", "pt-BR", "pt-PT", "ro-RO", "sk-SK", "sl-SI", "sr-Latn-RS", "fi-FI",
"sv-SE", "vi-VN", "tr-TR", "el-GR", "bg-BG", "ru-RU", "uk-UA", "he-IL", "ar-AE",
"ar-KW", "ar-SA", "ar-QA", "ar-EG", "ne-NP", "mr-IN", "hi-IN", "bn-IN", "ta-IN",
"te-IN", "th-TH", "ko-KR", "zh-Hant-HK", "ja-JP", "zh-Hans-CN", "zh-Hant-TW"]
```

#### Example Usage

```js
addOnUISdk.ready.then(async () => {
console.log(addOnUISdk.app.ui.format); // output "en-GB"
});
```

## Methods

### openEditorPanel
Expand Down Expand Up @@ -237,10 +265,14 @@ addOnUISdk.app.on("themechange", (data) => {
});
```

<InlineAlert slots="text" variant="success"/>

Please see the **swc** sample provided in the [code samples](../../samples.md) within the **contributed** folder as a reference for how to use the `theme` in your own add-on.

### localechange

**`localechange: string`**<br/>
The "localechange" event is fired when the user changes the UI theme in Adobe Express. It's used with the [`addOnUISdk.app.on`](../addonsdk/addonsdk-app.md) function.
The "localechange" event is fired when the user changes the UI locale in Adobe Express. It's used with the [`addOnUISdk.app.on`](../addonsdk/addonsdk-app.md) function.

#### Parameters

Expand All @@ -258,6 +290,23 @@ addOnUISdk.app.on("localechange", (data) => {
});
```

<InlineAlert slots="text" variant="success"/>
### formatchange

Please see the **swc** sample provided in the [code samples](../../samples.md) within the **contributed** folder as a reference for how to use the `theme` in your own add-on.
**`formatchange: string`**<br/>
The "formatchange" event is fired when the user changes the UI format in Adobe Express. It's used with the [`addOnUISdk.app.on`](../addonsdk/addonsdk-app.md) function.

#### Parameters

N/A

#### Return Value

N/A

#### Example Usage

```js
addOnUISdk.app.on("formatchange", (data) => {
console.log(data.format);
});
```
2 changes: 1 addition & 1 deletion src/pages/references/addonsdk/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This reference is provided to outline the interfaces, methods, properties and ev
- [Authorization with OAuth 2.0](../../guides/develop/use_cases/authentication_authorization.md#oauth-20)
- [Client-side Storage Access](../../guides/develop/use_cases/clientside_data.md)
- [Modal Dialogs](../../guides/develop/use_cases/user_interaction.md#modal-dialogs)
- [Locale Detection](../../guides/develop/use_cases/environment_settings.md#detecting-locale-and-supported-locales)
- [Locale Detection](../../guides/develop/use_cases/environment_settings.md#detecting-locale-supported-locales-and-format)
- [Theme Detection](../../guides/develop/use_cases/environment_settings.md#detecting-theme)
- [Access to the Manifest](/references/addonsdk/instance-manifest.md)
- [Access to the Document information](/references/addonsdk/app-document.md)
Expand Down
7 changes: 6 additions & 1 deletion src/pages/references/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ contributors:

# Changelog

## 2024-07-22

- Added a new [`format`](../references/addonsdk/app-ui.md#format) property to the `addOnUISdk.app.ui` object that reflects the format used to display dates, times, numbers, etc. in the user's environment. It supports a [`"formatchange"`](../references/addonsdk/app-ui.md#formatchange) event triggered when the format changes—see an example in the [Locale, Supported Locales, and Format](../guides/develop/use_cases/environment_settings.md#detecting-locale-supported-locales-and-format) section.
- Removed `mobile` and `app` as [`supportedDeviceClass`](../references/manifest/index.md#requirementsappssupporteddeviceclass) values in the Manifest's `requirements.apps` object.

## 2024-05-28

- Added a new *experimental* [`openEditorPanel()`](../references/addonsdk/app-ui.md#openeditorpanel) API to programmatically open and interact with the Editor panel. This method of the `addOnUISdk.app.ui` allows navigation to specific tabs and collections, as well as performing content searches. The [Constants](../references/addonsdk/addonsdk-constants.md) page has been updated accordingly.
Expand Down Expand Up @@ -317,7 +322,7 @@ Some items in the following list of changes may have been mentioned in recent up

**NOTE:** You can only delete add-ons that have not been published publicly or submitted to our Review team. Please contact us if you need to un-publish an add-on.

**Supported Languages:** The [version details step](../guides/distribute/public-dist.md#step-4-enter-listing-details) for publishing add-ons publicly now includes fields to indicate which languages are supported by your add-ons (beyond the required English). You can choose from any of the languages Express supports, and your designation will be shown to users when they browse your listing details. See [our sample for detecting a user's locale to localize your add-on](../guides/develop/use_cases/environment_settings.md#detecting-locale-and-supported-locales).
**Supported Languages:** The [version details step](../guides/distribute/public-dist.md#step-4-enter-listing-details) for publishing add-ons publicly now includes fields to indicate which languages are supported by your add-ons (beyond the required English). You can choose from any of the languages Express supports, and your designation will be shown to users when they browse your listing details. See [our sample for detecting a user's locale to localize your add-on](../guides/develop/use_cases/environment_settings.md#detecting-locale-supported-locales-and-format).
- Updated list of templates and details to include the [Document Sandbox template options](../guides/getting_started/dev_tooling.md#templates), and how to still scaffold from one when the [`--template` parameter is not explicitly supplied](../guides/getting_started/dev_tooling.md#no-template-parameter).
- New FAQ item regarding the mime type for exported PDF files. This is due to an unexpected change made in Adobe Express core to the mime type returned when you generate a PDF using the export [`createRenditions`](../references/addonsdk/app-document.md#createrenditions) method. In the past it would return `application/pdf`, but currently it returns `text/plain`. This is something to be aware of if you are inspecting the mime type in the response and failing if it's anything other than `application/pdf`.
- Removed NPS survey.
Expand Down
7 changes: 4 additions & 3 deletions src/pages/references/manifest/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ Each add-on bundle contains a `manifest.json` file at the root level which defin

#### requirements.apps.supportedDeviceClass

The following platform values are currently supported in the `supportedDeviceClass` key.
The following platform value is currently supported in the `supportedDeviceClass` key.

| Platform | Description |
| ----------------| -------------|
| `desktop` | Browser on desktop. |
| `mobile` | Browser on mobile and tablet devices. |
| `app` | Native app on mobile and tablet devices. |
<!-- Extra comment, otherwise the table will show the content anyway—bar the first cell -->
<!-- | `mobile` | Browser on mobile and tablet devices. | -->
<!-- | `app` | Native app on mobile and tablet devices. | -->

## entryPoints

Expand Down

0 comments on commit 149d326

Please sign in to comment.