Constructor
new SymbolInstance()
- Source:
Properties:
Name | Type | Description |
---|---|---|
symbolMaster |
Node | The symbolMaster object used by the instance |
Example
//Get any symbol instance
const instance = sketch.pages[0].get('symbolInstance', 'button');
console.log(`The instance named ${instance.name} belongs to the master symbol ${instance.symbolMaster.name}`);
//Get the symbol master named 'new-button'
const master = sketch.getSymbolsPage().get('symbolMaster', 'new-button');
//Apply the new master to the instance
instance.symbolMaster = master;
Extends
Members
parent
- Source:
- Inherited From:
Returns the parent element
Methods
clone(parent) → {Node}
- Source:
- Inherited From:
Creates a deep clone of this node
Parameters:
Name | Type | Description |
---|---|---|
parent |
Node | undefined | The new parent of the clone. If it's not defined use the current parent. |
Returns:
- Type
- Node
detach() → {Node}
- Source:
- Inherited From:
Removes the node from its parent
Returns:
- Type
- Node
get(type, conditionopt) → {Node|undefined}
- Source:
- Inherited From:
Search and returns the first descendant node that match the type and condition.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
String | The Node type | |
condition |
function | String |
<optional> |
The node name or a callback to be executed on each node that must return true or false. If it's not provided, only the type argument is be used. |
Returns:
- Type
- Node | undefined
getAll(type, conditionopt) → {Array.<Node>}
- Source:
- Inherited From:
Search and returns all descendant nodes matching with the type and condition.
Example
//Get the first page
const page = sketch.pages[0];
//Get all colors found in this page
const colors = page.getAll('color');
//Get all colors with specific values
const blueColors = page.getAll('color', (color) => {
return color.blue > 0.5 && color.red < 0.33
});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
String | The Node type | |
condition |
function | String |
<optional> |
The node name or a callback to be executed on each node that must return true or false. If it's not provided, only the type argument is be used. |
Returns:
- Type
- Array.<Node>
getParent(typeopt, conditionopt) → {Node|Sketch|undefined}
- Source:
- Inherited From:
Find a node ascendent matching with the type and condition
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
String |
<optional> |
The node type |
condition |
function | String |
<optional> |
The node name or a callback to be executed on each parent and must return true or false. If it's not provided, only the type argument is be used. |
Returns:
getSketch() → {Sketch|undefined}
- Source:
- Inherited From:
Get the sketch element associated with this node
Returns:
- Type
- Sketch | undefined
push(key, node) → {Node}
- Source:
- Inherited From:
Push a new children in this node
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The node key |
node |
Node | Object | The node/s to insert |
Returns:
The new node inserted
- Type
- Node
replaceWith(node) → {Node}
- Source:
- Inherited From:
Replace this node with other
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | The node to use |
Returns:
The new node
- Type
- Node
set(key, node)
- Source:
- Inherited From:
Add/replace new childrens in this node
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The node key |
node |
Node | Object | Array | The node/s to insert |
toJson() → {Object}
- Source:
- Inherited From:
Returns a json with the node data
Returns:
- Type
- Object