CodeBlockNode
Defined in: figmaPluginTypes.ts:9200
https://www.figma.com/plugin-docs/api/CodeBlockNode
readonlyabsoluteBoundingBox:null|Rect
Defined in: figmaPluginTypes.ts:5712
The bounds of the node that does not include rendered properties like drop shadows or strokes. The x and y inside this property represent the absolute position of the node on the page.
OpaqueNodeMixin.absoluteBoundingBox
readonlyabsoluteTransform:Transform
Defined in: figmaPluginTypes.ts:5708
The position of a node relative to its containing page as a Transform matrix.
OpaqueNodeMixin.absoluteTransform
readonlyattachedConnectors:ConnectorNode[]
Defined in: figmaPluginTypes.ts:5183
An array of ConnectorNodes that are attached to a node.
OpaqueNodeMixin.attachedConnectors
blendMode:
BlendMode
Defined in: figmaPluginTypes.ts:7182
Blend mode of this node, as shown in the Layer panel. In addition to the blend modes that paints & effects support, the layer blend mode can also have the value PASS_THROUGH.
readonlyoptionalboundVariables:object&object&object
Defined in: figmaPluginTypes.ts:5195
The variables bound to a particular field on this node. Please see the Working with Variables guide for how to get and set variable bindings.
optionalbottomLeftRadius:VariableAlias
optionalbottomRightRadius:VariableAlias
optionalcharacters:VariableAlias
optionalcounterAxisSpacing:VariableAlias
optionalheight:VariableAlias
optionalitemSpacing:VariableAlias
optionalmaxHeight:VariableAlias
optionalmaxWidth:VariableAlias
optionalminHeight:VariableAlias
optionalminWidth:VariableAlias
optionalopacity:VariableAlias
optionalpaddingBottom:VariableAlias
optionalpaddingLeft:VariableAlias
optionalpaddingRight:VariableAlias
optionalpaddingTop:VariableAlias
optionalstrokeBottomWeight:VariableAlias
optionalstrokeLeftWeight:VariableAlias
optionalstrokeRightWeight:VariableAlias
optionalstrokeTopWeight:VariableAlias
optionalstrokeWeight:VariableAlias
optionaltopLeftRadius:VariableAlias
optionaltopRightRadius:VariableAlias
optionalvisible:VariableAlias
optionalwidth:VariableAlias
optionalfontFamily:VariableAlias[]
optionalfontSize:VariableAlias[]
optionalfontStyle:VariableAlias[]
optionalfontWeight:VariableAlias[]
optionalletterSpacing:VariableAlias[]
optionallineHeight:VariableAlias[]
optionalparagraphIndent:VariableAlias[]
optionalparagraphSpacing:VariableAlias[]
readonlyoptionalcomponentProperties:object
[propertyName: string]: VariableAlias
readonlyoptionaleffects:VariableAlias[]
readonlyoptionalfills:VariableAlias[]
readonlyoptionallayoutGrids:VariableAlias[]
readonlyoptionalstrokes:VariableAlias[]
readonlyoptionaltextRangeFills:VariableAlias[]
OpaqueNodeMixin.boundVariables
code:
string
Defined in: figmaPluginTypes.ts:9208
The contents of the code block.
codeLanguage:
"TYPESCRIPT"|"CPP"|"RUBY"|"CSS"|"JAVASCRIPT"|"HTML"|"JSON"|"GRAPHQL"|"PYTHON"|"GO"|"SQL"|"SWIFT"|"KOTLIN"|"RUST"|"BASH"|"PLAINTEXT"|"DART"
Defined in: figmaPluginTypes.ts:9212
The language of the code block. New languages will be added to this enum without the major version updating, so be careful not to exhaustively match on this type without a default case.
componentPropertyReferences:
null| {characters?:string;mainComponent?:string;visible?:string; }
Defined in: figmaPluginTypes.ts:5187
All component properties that are attached on this node. A node can only have componentPropertyReferences if it is a component sublayer or an instance sublayer. It will be null otherwise. The value in the key-value pair refers to the component property name as returned by componentPropertyDefinitions on the containing component, component set or main component (for instances).
OpaqueNodeMixin.componentPropertyReferences
explicitVariableModes:
object
Defined in: figmaPluginTypes.ts:8250
The explicitly set modes for this node.
For SceneNodes, represents a subset of SceneNodeMixin.resolvedVariableModes.
Note that this does not include workspace and team-default modes.
[collectionId: string]: string
OpaqueNodeMixin.explicitVariableModes
exportSettings: readonly
ExportSettings[]
Defined in: figmaPluginTypes.ts:6748
List of export settings stored on the node. For help on how to change this value, see Editing Properties.
OpaqueNodeMixin.exportSettings
readonlyheight:number
Defined in: figmaPluginTypes.ts:5642
The height of the node. Use a resizing method to change this value.
readonlyid:string
Defined in: figmaPluginTypes.ts:4878
The unique identifier of a node. For example, 1:3. The node id can be used with methods such as PluginAPI.getNodeByIdAsync, but plugins typically don't need to use this since you can usually just access a node directly.
One possible use case for using the id is to have a serializable representation of a Figma node. To "deserialize" an id back into a node, pass it to PluginAPI.getNodeByIdAsync. This will return null if the node is no longer present in the document.
In the URLs for Figma files, node ids are hyphenated. However, for use with the API, node ids must use colons. For example, if a Figma file URL has the node id 1-3, you must convert it to 1:3.
readonlyoptionalinferredVariables:object&object
Defined in: figmaPluginTypes.ts:5248
An object, keyed by field, returning any variables that match the raw value of that field for the mode of the node (or the default variable value if no mode is set)
optionalbottomLeftRadius:VariableAlias[]
optionalbottomRightRadius:VariableAlias[]
optionalcharacters:VariableAlias[]
optionalcounterAxisSpacing:VariableAlias[]
optionalheight:VariableAlias[]
optionalitemSpacing:VariableAlias[]
optionalmaxHeight:VariableAlias[]
optionalmaxWidth:VariableAlias[]
optionalminHeight:VariableAlias[]
optionalminWidth:VariableAlias[]
optionalopacity:VariableAlias[]
optionalpaddingBottom:VariableAlias[]
optionalpaddingLeft:VariableAlias[]
optionalpaddingRight:VariableAlias[]
optionalpaddingTop:VariableAlias[]
optionalstrokeBottomWeight:VariableAlias[]
optionalstrokeLeftWeight:VariableAlias[]
optionalstrokeRightWeight:VariableAlias[]
optionalstrokeTopWeight:VariableAlias[]
optionalstrokeWeight:VariableAlias[]
optionaltopLeftRadius:VariableAlias[]
optionaltopRightRadius:VariableAlias[]
optionalvisible:VariableAlias[]
optionalwidth:VariableAlias[]
readonlyoptionalfills:VariableAlias[][]
readonlyoptionalstrokes:VariableAlias[][]
Inferred variables are only returned for a field when it is not using a bound variable.
Variables can be inferred from:
- The collections of variables used in the file
- Variables from subscribed libraries, provided the variable is used in the file
Variables can only be inferred when there is a single variable that matches the raw value used for the scope of the variable.
- i.e. For a property set to width: 100px, where there are two variables set to a value of 100 with the default scope, a value cannot be inferred as there are two matches.
- i.e. For a property set to width: 100px, where there is a variable set to 100 with a scope of "Width and height" and a variable set to 100 with a scope of "Corner radius", a value can be inferred as there is a single match for the given scope.
Inferred variables for fills and strokes return a list of results where the index matches that of node.fills and node.strokes.
- i.e. node.inferredVariables.fills[0] holds the inferred variables for node.fills[0]
OpaqueNodeMixin.inferredVariables
readonlyisAsset:boolean
Defined in: figmaPluginTypes.ts:5010
Returns true if Figma detects that a node is an asset, otherwise returns false. An asset is is either an icon or a raster image.
This property is useful if you’re building a plugin for code generation.
Note: This property uses a set of heuristics to determine if a node is an asset. At a high level an icon is a small vector graphic and an image is a node with an image fill.
locked:
boolean
Defined in: figmaPluginTypes.ts:5167
Whether the node is locked or not, preventing certain user interactions on the canvas such as selecting and dragging. Does not affect a plugin's ability to write to those properties.
The value that this property returns is independent from the node's parent. i.e.
- The node isn't necessarily locked if this is
.locked === true. - The node isn't necessarily unlocked if this is
.locked === false. - An object is locked if
.locked == truefor itself or any of its parents.
maxHeight:
null|number
Defined in: figmaPluginTypes.ts:5658
Applicable only to auto-layout frames and their direct children. Value must be positive. Set to null to remove maxHeight.
maxWidth:
null|number
Defined in: figmaPluginTypes.ts:5650
Applicable only to auto-layout frames and their direct children. Value must be positive. Set to null to remove maxWidth.
minHeight:
null|number
Defined in: figmaPluginTypes.ts:5654
Applicable only to auto-layout frames and their direct children. Value must be positive. Set to null to remove minHeight.
minWidth:
null|number
Defined in: figmaPluginTypes.ts:5646
Applicable only to auto-layout frames and their direct children. Value must be positive. Set to null to remove minWidth.
name:
string
Defined in: figmaPluginTypes.ts:4898
The name of the layer that appears in the layers panel. Calling figma.root.name will return the name, read-only, of the current file.
If the node is a TextNode, the name will update automatically by default based on the characters property (autoRename is true). If you manually override the text node's name, it will set autoRename to false. This matches the behavior in the editor.
If the node is a PageNode with no children and the name is a page divider name, it will set isPageDivider to true. A page divider name consists of all asterisks, all en dashes, all em dashes, or all spaces.
opacity:
number
Defined in: figmaPluginTypes.ts:7178
Opacity of the node, as shown in the Layer panel. Must be between 0 and 1.
readonlyparent:null| BaseNode & ChildrenMixin
Defined in: figmaPluginTypes.ts:4888
Returns the parent of this node, if any. This property is not meant to be directly edited. To reparent, see ChildrenMixin.appendChild.
The root node (i.e. figma.root) doesn't have a parent.
Components accessed via instance.getMainComponentAsync() or instance.mainComponent do not always have a parent. They could be remote components or soft-deleted components.
relativeTransform:
Transform
Defined in: figmaPluginTypes.ts:5704
The position of a node relative to its containing parent as a Transform matrix. Not used for scaling, see width and height instead. Read the details page to understand the nuances of this property.
The relativeTransform is not used for scaling a node. The transform always has unit axes. That is, sqrt(m00^2 + m10^2) == sqrt(m01^2 + m11^2) == 1. In order to set the size of a node, use LayoutMixin.resize or LayoutMixin.resizeWithoutConstraints.
Note: If you have a background in computer graphics, you may find it odd that we use the transform matrix in such a manner. This is because in 2D UI design, it's rare that you would want to scale the children when resizing a frame. And even if you did, it would be through more nuanced constraint settings that aren't captured by a transformation matrix.
Also, if nodes had both a width and a separate m00 scale property, it would be confusing to the users which one they're changing, especially during interactions like dragging.
The relative transform of a node is shown relative to its container parent, which includes canvas nodes, frame nodes, component nodes, and instance nodes. Just like in the properties panel, it is not relative to its direct parent if the parent is a group or a boolean operation.
Example 1: In the following hierarchy, the relative transform of rectangle is relative to page (which is just its position on the canvas).
page
group
rectangle
Example 2: In the following hierarchy, the relative transform of rectangle is relative to frame.
page
frame
boolean operation
rectangle
One implication is that to calculate the absolute position of a node, you have to either use the DimensionAndPositionMixin.absoluteTransform property or multiply relative transform matrices while traversing up the node hierarchy while ignoring groups and boolean operations.
Note: Why this complication? We do it this way because groups and boolean operations automatically resize to fit their children. While you can set the relative transform of a group to move it, it's a property derived from the position and size of its children. If the relative transform was always relative to it’s immediate parent, you could get into confusing situations where moving a layer inside a group by setting the relative transform changes the position of the parent, which then requires changing the relative transform of the child in order to preserve its on-screen position!
While it is possible to skew a layer by setting m00, m01, m10, m11 to the right values, be aware that the skew will not be surfaced in the properties panel and may be confusing to the user dealing with a skewed node.
The translation components m02 and m12 of the transform matrix is automatically computed in children of auto-layout frames. Setting relativeTransform on those layers will ignore the translation components, but do keep the rotation components.
OpaqueNodeMixin.relativeTransform
readonlyremoved:boolean
Defined in: figmaPluginTypes.ts:4911
Returns true if this node has been removed since it was first accessed. If your plugin stays open for a while and stores references to nodes, you should write your code defensively and check that the nodes haven't been removed by the user.
A node can be removed for any number of reasons. Some examples:
- Your plugin called node.remove() on it
- Someone else deleted the node using multiplayer
- The user triggered an undo action and the node was removed
- The user simply deleted the node
- You removed all children out of a group, and the group auto-deleted itself
resolvedVariableModes:
object
Defined in: figmaPluginTypes.ts:5292
The resolved mode for this node for each variable collection in this file.
[collectionId: string]: string
The set of resolved modes on a node includes the explicitly set modes on the node, as well as the explicitly set modes on ancestors of the node. By default, nodes automatically inherit the modes of their parents.
// Create two collections with two modes each
const collection1 = figma.variables.createVariableCollection("Collection 1");
const collection1Mode1Id = collection1.modes[0].modeId;
const collection1Mode2Id = collection1.addMode("Mode 2");
const collection2 = figma.variables.createVariableCollection("Collection 2");
const collection2Mode1Id = collection2.modes[0].modeId;
const collection2Mode2Id = collection2.addMode("Mode 2");
const parentFrame = figma.createFrame();
const childFrame = figma.createFrame();
parentFrame.appendChild(childFrame);
parentFrame.setExplicitVariableModeForCollection(
collection1,
collection1Mode2Id
);
childFrame.setExplicitVariableModeForCollection(
collection2,
collection2Mode1Id
);
// Example output (only collection2 is present):
// { 'VariableCollectionId:1:3': '1:2' }
console.log(childFrame.explicitVariableModes);
// Example output (both collections are present):
// { 'VariableCollectionId:1:2': '1:1', 'VariableCollectionId:1:3': '1:2' }
console.log(childFrame.resolvedVariableModes);OpaqueNodeMixin.resolvedVariableModes
readonlystuckNodes:SceneNode[]
Defined in: figmaPluginTypes.ts:5179
An array of nodes that are "stuck" to this node. In FigJam, stamps, highlights, and some widgets can "stick" to other nodes if they are dragged on top of another node.
This property is only available in FigJam.
In FigJam a stickable host that means that stickables, like 'STAMP' nodes, are allowed to attach themselves to the node. If the stickable host moves all nodes that are in stuckNodes move along with it.
readonlytype:"CODE_BLOCK"
Defined in: figmaPluginTypes.ts:9204
The type of this node, represented by the string literal "CODE_BLOCK"
visible:
boolean
Defined in: figmaPluginTypes.ts:5156
Whether the node is visible or not. Does not affect a plugin's ability to access the node.
The value that this property returns is independent from the node's parent. i.e.
- The node isn't necessarily visible if this is
.visible === true. - The node isn't necessarily invisible if this is
.visible === false. - An object is visible if
.visible == truefor itself and all its parents.
readonlywidth:number
Defined in: figmaPluginTypes.ts:5638
The width of the node. Use a resizing method to change this value.
x:
number
Defined in: figmaPluginTypes.ts:5626
The position of the node. Identical to relativeTransform[0][2].
This value is automatically computed in children of auto-layout frames. Setting this property for these auto-layout children will no-op.
y:
number
Defined in: figmaPluginTypes.ts:5634
The position of the node. Identical to relativeTransform[1][2].
This value is automatically computed in children of auto-layout frames. Setting this property for these auto-layout children will no-op.
addDevResourceAsync(
url,name?):Promise<void>
Defined in: figmaPluginTypes.ts:5100
Adds a dev resource to a node. This will fail if the node already has a dev resource with the same url.
string
The url of the dev resource.
string
The name of the dev resource. If not provided, Figma will get the name from the url.
Promise<void>
OpaqueNodeMixin.addDevResourceAsync
clearExplicitVariableModeForCollection(
collectionId):void
Defined in: figmaPluginTypes.ts:8258
Clears an explicit mode for the given collection on this node
string
void
Use clearExplicitVariableModeForCollection(VariableCollection) instead. This function will throw an exception if the plugin manifest contains "documentAccess": "dynamic-page".
OpaqueNodeMixin.clearExplicitVariableModeForCollection
clearExplicitVariableModeForCollection(
collection):void
Defined in: figmaPluginTypes.ts:8264
Clears an explicit mode for the given collection on this node
A variable collection. Make sure to pass a collection object here; passing a variable collection ID is deprecated.
void
OpaqueNodeMixin.clearExplicitVariableModeForCollection
clone():
CodeBlockNode
Defined in: figmaPluginTypes.ts:9233
Duplicates the node. By default, the duplicate will be parented under figma.currentPage.
CodeBlockNode
deleteDevResourceAsync(
url):Promise<void>
Defined in: figmaPluginTypes.ts:5122
Deletes a dev resource on a node. This will fail if the node does not have a dev resource with the same url.
string
The url of the dev resource.
Promise<void>
OpaqueNodeMixin.deleteDevResourceAsync
editDevResourceAsync(
currentUrl,newValue):Promise<void>
Defined in: figmaPluginTypes.ts:5109
Edits a dev resource on a node. This will fail if the node does not have a dev resource with the same url.
string
The current url of the dev resource.
The new name and/or url of the dev resource.
string
string
Promise<void>
OpaqueNodeMixin.editDevResourceAsync
exportAsync(
settings?):Promise<Uint8Array<ArrayBufferLike>>
Defined in: figmaPluginTypes.ts:6811
Exports the node as an encoded image.
If the manifest contains "documentAccess": "dynamic-page", and the node is a PageNode, you must first call PageNode.loadAsync to access this function.
When this parameter is absent, this function defaults to exporting as a PNG at 1x resolution.
Note that the result is a Uint8Array, representing the bytes of the image file (encoded in the specified format).
(async () => {
const polygon = figma.createPolygon();
polygon.pointCount = 6;
polygon.fills = [{ type: "SOLID", color: { r: 1, g: 0, b: 0 } }];
// highlight-start
// Export a 2x resolution PNG of the node
const bytes = await polygon.exportAsync({
format: "PNG",
constraint: { type: "SCALE", value: 2 },
});
// highlight-end
// Add the image onto the canvas as an image fill in a frame
const image = figma.createImage(bytes);
const frame = figma.createFrame();
frame.x = 200;
frame.resize(200, 230);
frame.fills = [
{
imageHash: image.hash,
scaleMode: "FILL",
scalingFactor: 1,
type: "IMAGE",
},
];
})();(async () => {
// Create a triangle using the VectorPath API
const vector = figma.createVector();
vector.vectorPaths = [
{
windingRule: "EVENODD",
data: "M 0 100 L 100 100 L 50 0 Z",
},
];
// highlight-start
// Export the vector to SVG
const svg = await vector.exportAsync({ format: "SVG_STRING" });
// highlight-end
console.log(svg);
})();(async () => {
const json = await figma.currentPage.selection[0].exportAsync({
format: "JSON_REST_V1",
});
// Return a JSON object in the same format as the Figma REST API response
console.log(json.document);
})();Promise<Uint8Array<ArrayBufferLike>>
exportAsync(
settings):Promise<string>
Defined in: figmaPluginTypes.ts:6812
Promise<string>
exportAsync(
settings):Promise<Object>
Defined in: figmaPluginTypes.ts:6813
Promise<Object>
getCSSAsync():
Promise<{[key:string]:string; }>
Defined in: figmaPluginTypes.ts:5014
Resolves to a JSON object of CSS properties of the node. This is the same CSS that Figma shows in the inspect panel and is helpful if you are building a plugin for code generation.
Promise<{[key: string]: string; }>
getDevResourcesAsync(
options?):Promise<DevResourceWithNodeId[]>
Defined in: figmaPluginTypes.ts:5091
Gets all of the dev resources on a node. This includes any inherited dev resources from components and component sets.
An optional parameter to include getting all of the dev resources on the children of the node. Defaults to false.
boolean
Promise<DevResourceWithNodeId[]>
OpaqueNodeMixin.getDevResourcesAsync
getPluginData(
key):string
Defined in: figmaPluginTypes.ts:5031
Retrieves custom information that was stored on this node or style using PluginDataMixin.setPluginData. If there is no data stored for the provided key, an empty string is returned.
string
string
getPluginDataKeys():
string[]
Defined in: figmaPluginTypes.ts:5053
Retrieves a list of all keys stored on this node or style using using PluginDataMixin.setPluginData. This enables iterating through all data stored privately on a node or style by your plugin.
string[]
OpaqueNodeMixin.getPluginDataKeys
getRelaunchData():
object
Defined in: figmaPluginTypes.ts:5000
Retreives the reluanch data stored on this node using BaseNodeMixin.setRelaunchData
object
OpaqueNodeMixin.getRelaunchData
getSharedPluginData(
namespace,key):string
Defined in: figmaPluginTypes.ts:5057
Retrieves custom information that was stored on this node or style using PluginDataMixin.setSharedPluginData. If there is no data stored for the provided namespace and key, an empty string is returned.
string
string
string
OpaqueNodeMixin.getSharedPluginData
getSharedPluginDataKeys(
namespace):string[]
Defined in: figmaPluginTypes.ts:5079
Retrieves a list of all keys stored on this node or style using PluginDataMixin.setSharedPluginData. This enables iterating through all data stored in a given namespace.
string
string[]
OpaqueNodeMixin.getSharedPluginDataKeys
getTopLevelFrame():
undefined|FrameNode
Defined in: figmaPluginTypes.ts:5022
Returns the top-most frame that contains this node. If the node is not inside a frame, this will return undefined.
Note: This function will only work in Figma Design and will throw an error if called in FigJam or Slides.
undefined | FrameNode
OpaqueNodeMixin.getTopLevelFrame
remove():
void
Defined in: figmaPluginTypes.ts:4933
Removes this node and all of its children from the document.
void
If you want to only remove this node but not its children, you will have to first move them to another node before calling remove().
setBoundVariable(
field,variableId):void
Defined in: figmaPluginTypes.ts:5214
Binds the provided field on this node to the given variable. Please see the Working with Variables guide for how to get and set variable bindings.
VariableBindableTextField | VariableBindableNodeField
null | string
void
Use setBoundVariable(VariableBindableNodeField, Variable) instead. This function will throw an exception if the plugin manifest contains "documentAccess": "dynamic-page".
OpaqueNodeMixin.setBoundVariable
setBoundVariable(
field,variable):void
Defined in: figmaPluginTypes.ts:5226
Binds the provided field on this node to the given variable. Please see the Working with Variables guide for how to get and set variable bindings.
If null is provided as the variable, the given field will be unbound from any variables.
The field to bind the variable to.
VariableBindableTextField | VariableBindableNodeField
The variable to bind to the field. If null is provided, the field will be unbound from any variables. Make sure to pass a Variable object or null; passing a variable ID is deprecated.
null | Variable
void
OpaqueNodeMixin.setBoundVariable
setDevResourcePreviewAsync(
url,preview):Promise<void>
Defined in: figmaPluginTypes.ts:5127
Caution: This is a private API only available to Figma partners
string
Promise<void>
OpaqueNodeMixin.setDevResourcePreviewAsync
setExplicitVariableModeForCollection(
collectionId,modeId):void
Defined in: figmaPluginTypes.ts:8270
Sets an explicit mode for the given collection on this node
string
string
void
Use setExplicitVariableModeForCollection(VariableCollection, Variable) instead. This function will throw an exception if the plugin manifest contains "documentAccess": "dynamic-page".
OpaqueNodeMixin.setExplicitVariableModeForCollection
setExplicitVariableModeForCollection(
collection,modeId):void
Defined in: figmaPluginTypes.ts:8277
Sets an explicit mode for the given collection on this node
A variable collection. Make sure to pass a collection object here; passing a variable collection ID is deprecated.
string
A variable mode ID.
void
OpaqueNodeMixin.setExplicitVariableModeForCollection
setPluginData(
key,value):void
Defined in: figmaPluginTypes.ts:5049
Lets you store custom information on any node or style, private to your plugin. The total size of your entry (pluginId, key, value) cannot exceed 100 kB.
string
The key under which to store the data. This is similar to writing to a plain object via obj[key] = value.
string
The data you want to store. If you want to store a value type other than a string, encode it as a JSON string first via JSON.stringify and JSON.parse. If you set the value to the empty string (""), the key/value pair is removed.
void
The data is specific to your plugin ID. Plugins with other IDs won't be able to read this data. You can retrieve it later by calling getPluginData with the same key. To find all data stored on a node or style by your plugin use getPluginDataKeys.
Caution: ⚠ The data is stored privately for stability, not security. It prevents other plugins from accessing with your data. It does not, however, prevent users from seeing the data given sufficient effort. For example, they could export the document as a .fig file and try to decode it.
Caution: ⚠ Data will become inaccessible if your plugin ID changes.
Caution: ⚠ Total entry size cannot exceed 100 kB.
setRelaunchData(
data):void
Defined in: figmaPluginTypes.ts:4996
Sets state on the node to show a button and description when the node is selected. Clears the button and description when relaunchData is {}.
Note: In Figma and Dev Mode, this shows up in the properties panel. In FigJam, this shows up in the property menu. See here for examples.
{
[command: string]: string // description
}e.g. data = { myCommand: 'Short description' }
void
Each call to this method sets entirely new relaunch data, removing any relaunch data and associated buttons/descriptions from before. To maintain buttons from a previous call one can store the button information using setPluginData and later fetch it with getPluginData before passing it on to setRelaunchData.
To use this API, the plugin manifest must include a relaunchButtons section: see the manifest guide for more information.
Note: Note that if the command passed to this method does not match a command in the manifest, nothing will be displayed. Similarly if the name of a command in the manifest changes or is removed, then all buttons with that command will disappear. This behavior can be used to remove buttons when a particular action is no longer supported by the plugin.
In Figma design, the relaunch data can also be placed on the PageNode or DocumentNode, to show a button and description when nothing is selected. Relaunch buttons added to the PageNode will be displayed on that page, combined with buttons from the DocumentNode that show on every page. This is not supported in FigJam.
// With the following in the manifest:
"relaunchButtons": [
{"command": "edit", "name": "Edit shape"},
{"command": "open", "name": "Open Shaper", "multipleSelection": true}
]// Add two buttons (ordered by the above array from the manifest):
// * an "Edit shape" button with a description of "Edit this trapezoid
// with Shaper" that runs the plugin with `figma.command === 'edit'`.
// * an "Open Shaper" button with no description that runs the plugin with
// `figma.command === 'open'`.
node.setRelaunchData({ edit: 'Edit this trapezoid with Shaper', open: '' })
// With the following in the manifest:
"relaunchButtons": [
{"command": "relaunch", "name": "Run again", "multipleSelection": true}
]
// Pass an empty description to show only a button
node.setRelaunchData({ relaunch: '' })
// Remove the button and description
node.setRelaunchData({})OpaqueNodeMixin.setRelaunchData
setSharedPluginData(
namespace,key,value):void
Defined in: figmaPluginTypes.ts:5075
Lets you store custom information on any node or style, public to all plugins. The total size of your entry (namespace, key, value) cannot exceed 100 kB.
string
A unique string to identify your plugin and avoid key collisions with other plugins. The namespace must be at least 3 alphanumeric characters.
string
The key under which to store the data. This is similar to writing to a plain object via obj[key] = value.
string
The data you want to store. If you want to store a value type other than a string, encode it as a JSON string first via JSON.stringify and JSON.parse. If you set the value to the empty string (""), the key/value pair is removed.
void
This lets you store custom information on any node or style. You can retrieve it later by calling PluginDataMixin.getSharedPluginData with the same namespace and key. To find all data stored on a node or style in a particular namespace, use PluginDataMixin.getSharedPluginDataKeys.
Any data you write using this API will be readable by any plugin. The intent is to allow plugins to interoperate with each other. Use PluginDataMixin.setPluginData instead if you don't want other plugins to be able to read your data.
You must also provide a namespace argument to avoid key collisions with other plugins. This argument is mandatory to prevent multiple plugins from using generic key names like data and overwriting one another. We recommend passing a value that identifies your plugin. This namespace can be given to authors of other plugins so that they can read data from your plugin.
Caution: ⚠ Total entry size cannot exceed 100 kB.
OpaqueNodeMixin.setSharedPluginData
toString():
string
Defined in: figmaPluginTypes.ts:4925
Returns a string representation of the node. For debugging purposes only, do not rely on the exact output of this string in production code.
string
This currently returns a string of the form [Node ID] where ID is the id of the node. This is just for debugging convenience so the node displays something useful when converted to a string. We recommend not relying on this in production.
Example:
// e.g. [Node 0:5]
console.log(`Current selected node ${figma.currentPage.selection[0]}`);
