From 375c3b3cc4e0ff33d2a57720c001a00fc0122d9b Mon Sep 17 00:00:00 2001 From: DaveInMatrix <70600982+DaveInMatrix@users.noreply.github.com> Date: Mon, 22 Nov 2021 16:53:03 -0800 Subject: [PATCH 1/2] Added new component APIs --- src/pages/develop/changelog/index.md | 7 ++ src/pages/develop/reference/SymbolInstance.md | 102 ++++++++++++++++++ src/pages/develop/reference/assets.md | 33 ++++++ 3 files changed, 142 insertions(+) diff --git a/src/pages/develop/changelog/index.md b/src/pages/develop/changelog/index.md index 1377b6fee..6b0c97dc0 100644 --- a/src/pages/develop/changelog/index.md +++ b/src/pages/develop/changelog/index.md @@ -8,6 +8,13 @@ keywords: # Changelog +## XD Release 47 (December 2021) + +### New API Features + +* [SymbolInstance](/develop/reference/SymbolInstance) APIs to get read-only information on Components +* [assets.symbols.get()](/develop/reference/assets/#symbolsget) function to list Component assets + ## XD Release 45 (October 2021) ### New API Features diff --git a/src/pages/develop/reference/SymbolInstance.md b/src/pages/develop/reference/SymbolInstance.md index 42135a614..ffc4e7cb6 100644 --- a/src/pages/develop/reference/SymbolInstance.md +++ b/src/pages/develop/reference/SymbolInstance.md @@ -50,3 +50,105 @@ those changes are synced to all other instances of the component (unless blocked **Kind**: instance property of [SymbolInstance](#symbolinstance) **Read only**: true + +## stateId + +▸ **stateId**: `?string` + +**Since**: XD 47 + +Returns a unique GUID string representing the state identification, or null if there is only one state. The GUID string will be a combination of digits, lower-case letters, and dashes. All instances of a component will have the same state IDs for the same states. + +**Kind**: instance property of [SymbolInstance](#symbolinstance) +**Read only**: true + +## stateName + +▸ **stateName**: `string` + +**Since**: XD 47 + +Returns the name of the currently active state of the component. + +**Kind**: instance property of [SymbolInstance](#symbolinstance) +**Read only**: true + +## hasOverrides + +▸ **hasOverrides**: `boolean` + +**Since**: XD 47 + +Returns true if the currently active state has one or more overrides that differ from the master instance of the component. + +**Kind**: instance property of [SymbolInstance](#symbolinstance) +**Read only**: true + +## isDefaultState + +▸ **isDefaultState**: `boolean` + +**Since**: XD 47 + +Returns true if the currently active state is displaying the default state of the component. + +**Kind**: instance property of [SymbolInstance](#symbolinstance) +**Read only**: true + +## defaultState + +▸ **defaultState**: [SymbolInstance](#symbolinstance) + +**Since**: XD 47 + +Returns a [SymbolInstance](#symbolinstance) that is the default state of the component. + +**Kind**: instance property of [SymbolInstance](#symbolinstance) +**Read only**: true + +## isActiveState + +▸ **isActiveState**: `boolean` + +**Since**: XD 47 + +Returns true if the component state is the currently active state (being displayed on canvas). + +**Kind**: instance property of [SymbolInstance](#symbolinstance) +**Read only**: true + +## activeState + +▸ **activeState**: [SymbolInstance](#symbolinstance) + +**Since**: XD 47 + +Returns a [SymbolInstance](#symbolinstance) that is the active state of the component. + +**Kind**: instance property of [SymbolInstance](#symbolinstance) +**Read only**: true + +## getState() + +▸ **getState(stateId)**: [SymbolInstance](#symbolinstance) + +**Since**: XD 47 + +Returns a [SymbolInstance](#symbolinstance) that is the state with the given state ID. Returns null if the state ID is not valid, or if the state is not found in the component. + +| Param | Type | +| --------- | ------------------- | +| `stateId` | `string` | + +**Kind**: instance method of [SymbolInstance](#symbolinstance) + +## statesInfo + +▸ **statesInfo**: `Array.` + +**Since**: XD 47 + +Returns an array containing information about all the states in the component. For each state it returns an object containing the state ID, state name and whether it is the default state. + +**Kind**: instance property of [SymbolInstance](#symbolinstance) +**Read only**: true diff --git a/src/pages/develop/reference/assets.md b/src/pages/develop/reference/assets.md index fe555a519..d64ff059c 100644 --- a/src/pages/develop/reference/assets.md +++ b/src/pages/develop/reference/assets.md @@ -264,3 +264,36 @@ var assets = require("assets"), ``` **Kind**: static method of [characterStyles](#module_assets-characterStyles) + +## symbols + +▸ **symbols** + +**Since**: XD 47 + +The collection of [Components](/develop/reference/SymbolInstance) (previously known as "Symbols" in XD's UI) saved in this document's assets library. + +- [.symbols](#module_assets-symbols) + - [.get()](#symbolsget): Array.<[SymbolInstance](/develop/reference/SymbolInstance)> + +--- +### symbols.get() + +▸ **symbols.get**(): Array.<[SymbolInstance](/develop/reference/SymbolInstance)> + +**Since**: XD 47 + +Get a list of all canonical [component](/develop/reference/SymbolInstance) assets in the order they appear in the Assets panel. + +If there are no component assets, an empty array is returned. + +**Example** + +```js +const assets = require("assets"); +const allComponentAssets = assets.symbols.get(); +``` + +**Kind**: static method of [symbols](#symbols) + +--- From 6d410ee02a7f95a600a2c7739eed9d496d00b010 Mon Sep 17 00:00:00 2001 From: DaveInMatrix <70600982+DaveInMatrix@users.noreply.github.com> Date: Mon, 29 Nov 2021 18:54:11 -0800 Subject: [PATCH 2/2] Added note --- src/pages/develop/reference/SymbolInstance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/develop/reference/SymbolInstance.md b/src/pages/develop/reference/SymbolInstance.md index ffc4e7cb6..8d37b41cf 100644 --- a/src/pages/develop/reference/SymbolInstance.md +++ b/src/pages/develop/reference/SymbolInstance.md @@ -101,7 +101,7 @@ Returns true if the currently active state is displaying the default state of th **Since**: XD 47 -Returns a [SymbolInstance](#symbolinstance) that is the default state of the component. +Returns a [SymbolInstance](#symbolinstance) that is the default state of the component. The SymbolInstance returned may or may not be in the scenegraph, therefore it cannot be relied upon for traversing the SceneNode hierarchy. **Kind**: instance property of [SymbolInstance](#symbolinstance) **Read only**: true