### Get All Published Libraries in a Team Source: https://developers.mastergo.com/rest-api This GET endpoint retrieves all published library content for a given team. Ensure the 'X-MG-Authentication' header is included. ```http GET /openapi/v1/team/:teamId/libraries ``` -------------------------------- ### Get All Published Components in a Team Source: https://developers.mastergo.com/rest-api Use this GET endpoint to retrieve a list of all published components within a specific team. Requires an authentication header. ```http GET /openapi/v1/team/:teamId/components ``` -------------------------------- ### Response for Getting All Published Components Source: https://developers.mastergo.com/rest-api This JSON structure details the response when fetching all published components for a team. It includes component-specific information and metadata. ```json { "code": "string", "data": [ { "componentSetUkey": "string", "cover": "string", "createdAt": "string", "description": "string", "documentId": 0, "height": 0.0, "lastUpdator": { "avatar": "string", "id": 0, "name": "string" }, "layerId": "string", "name": "string", "pageInfo": { "backgroundColor": "string", "frameName": "string", "layerId": "string", "pageId": "string", "pageName": "string" }, "type": "string", "ukey": "string", "updatedAt": "string", "width": 0.0 } ], "meta": { "time": 0, "trace": "string" }, "msg": "string" } ``` -------------------------------- ### Successful Response (200 OK) Source: https://developers.mastergo.com/rest-api This is an example of a successful response from the API, indicating an 'OK' status. It includes a 'code' field, a 'data' object containing 'teamLibrary' information, and a 'meta' object for tracking. ```json { "code": "string", "data": { "teamLibrary": [ { "componentSets": [ { "cover": "string", "createdAt": "string", "description": "string", "documentId": 0, "lastUpdator": { "avatar": "string", "id": 0, "name": "string" }, "layerId": "string", "name": "string", "pageInfo": { "backgroundColor": "string", "frameName": "string", "layerId": "string", "pageId": "string", "pageName": "string" }, "ukey": "string", "updatedAt": "string" } ], "components": [ { "componentSetUkey": "string", "cover": "string", "createdAt": "string", "description": "string", "documentId": 0, "height": 0.0, "lastUpdator": { "avatar": "string", "id": 0, "name": "string" }, "layerId": "string", "name": "string", "pageInfo": { "backgroundColor": "string", "frameName": "string", "layerId": "string", "pageId": "string", "pageName": "string" }, "type": "string", "ukey": "string", "updatedAt": "string", "width": 0.0 } ], "createdAt": "string", "creator": { "avatar": "string", "id": 0, "name": "string" }, "documentId": 0, "documentName": "string", "id": "string", "projectId": 0, "publishedScope": "string", "styles": [ { "cover": "string", "createdAt": "string", "description": "string", "documentId": 0, "lastUpdator": { "avatar": "string", "id": 0, "name": "string" }, "name": "string", "sortIndex": "string", "styleSubType": 0, "styleType": "string", "ukey": "string", "updatedAt": "string" } ], "teamId": 0, "updatedAt": "string" } ] }, "meta": { "time": 0, "trace": "string" }, "msg": "string" } ``` -------------------------------- ### Get Shared Plugin Data Keys Source: https://developers.mastergo.com/apis/sectionNode.html Retrieves all keys for data stored under a specific namespace on the node. ```typescript getSharedPluginDataKeys(namespace: string): string[] ``` -------------------------------- ### Set Line Height for Text Nodes and Styles Source: https://developers.mastergo.com/updates This example shows how to set line height for text nodes and text styles using 'AUTO' or percentage values. It demonstrates using `setRangeLineHeight` for text nodes and direct assignment for text styles. ```typescript const textNode = mg.createText(); textNode.characters = 'text' //自动行高 textNode.setRangeLineHeight(0, 3, { unit: 'AUTO' }); console.log(textNode.textStyles[0].textStyle.lineHeight); // { unit: 'AUTO' } //百分比行高 textNode.setRangeLineHeight(0, 3, { unit: 'PERCENT', value: 50 }); console.log(textNode.textStyles[0].textStyle.lineHeight); // { unit: 'PERCENT', value: 50 } //创建文字样式 const textStyle = mg.createTextStyle({ id: textNode.id, name: 'textStyle', description: 'desc' }) //自动行高 textStyle.lineHeight = { unit: 'AUTO' }; console.log(textStyle.lineHeight); // { unit: 'AUTO' } //百分比行高 textStyle.lineHeight = { unit: 'PERCENT', value: 50 }; console.log(textStyle.lineHeight); // { unit: 'PERCENT', value: 50 } ``` -------------------------------- ### Get Plugin Data Keys from SectionNode Source: https://developers.mastergo.com/apis/sectionNode.html Retrieves all keys for custom information stored by the current plugin on the node. ```typescript getPluginDataKeys(): string[] ``` -------------------------------- ### GET /openapi/v1/componentSet Source: https://developers.mastergo.com/rest-api Retrieves the details of a specific component set using its unique key. This endpoint is useful for fetching comprehensive information about a component set, including its cover, description, and associated page details. ```APIDOC ## GET /openapi/v1/componentSet ### Description Retrieves the details of a specific component set using its unique key. This endpoint is useful for fetching comprehensive information about a component set, including its cover, description, and associated page details. ### Method GET ### Endpoint /openapi/v1/componentSet ### Parameters #### Query Parameters - **ukey** (string) - Required - The unique key of the component set. Obtainable from the "Team Library" interface documentation. #### Request Body None ### Response #### Success Response (200) - **code** (string) - OK if successful, error code otherwise. - **data** (object) - Contains the component set details. - **cover** (string) - Component set cover. - **createdAt** (string) - Component set creation time. - **description** (string) - Component set description. - **documentId** (integer) - The ID of the document the component set belongs to. - **lastUpdator** (object) - Information about the last person to update the component set. - **avatar** (string) - User avatar. - **id** (integer) - User ID. - **name** (string) - User name. - **layerId** (string) - The ID of the layer the component set belongs to. - **name** (string) - Component set name. - **pageInfo** (object) - Information about the component set's page. - **backgroundColor** (string) - Background color. - **frameName** (string) - Container name. - **layerId** (string) - Layer ID. - **pageId** (string) - Page ID. - **pageName** (string) - Page name. - **ukey** (string) - The unique key of the component set. - **updatedAt** (string) - Component set update time. - **meta** (object) - Metadata for the response. - **time** (integer) - Processing time. - **trace** (string) - Trace ID for troubleshooting. - **msg** (string) - Message indicating the status of the operation. #### Response Example ```json { "code": "string", "data": { "cover": "string", "createdAt": "string", "description": "string", "documentId": 0, "lastUpdator": { "avatar": "string", "id": 0, "name": "string" }, "layerId": "string", "name": "string", "pageInfo": { "backgroundColor": "string", "frameName": "string", "layerId": "string", "pageId": "string", "pageName": "string" }, "ukey": "string", "updatedAt": "string" }, "meta": { "time": 0, "trace": "string" }, "msg": "string" } ``` ``` -------------------------------- ### Get Shared Plugin Data Source: https://developers.mastergo.com/apis/sectionNode.html Retrieves shared data stored under a specific namespace. Use the same namespace and key to retrieve it later. ```typescript getSharedPluginData(namespace: string, key: string): string ``` -------------------------------- ### GET /openapi/v1/team/:teamId/libraries Source: https://developers.mastergo.com/rest-api Fetches all published library content for a specified team. This endpoint is useful for retrieving a list of all available team libraries. ```APIDOC ## GET /openapi/v1/team/:teamId/libraries ### Description Fetches all published library content for a specified team. This endpoint is useful for retrieving a list of all available team libraries. ### Method GET ### Endpoint /openapi/v1/team/:teamId/libraries ### Headers - **X-MG-Authentication** (string) - Required - OPENAPI authentication header ### Parameters #### Path Parameters - **teamId** (string) - Required - The ID of the team #### Response #### Success Response (200) - **code** (string) - OK if the request was successful - **data** (array) - An array of library objects - **cover** (string) - Optional - The cover image of the library - **createdAt** (string) - Optional - The creation time of the library - **description** (string) - Optional - The description of the library - **documentId** (integer) - Optional - The ID of the document the library belongs to - **lastUpdator** (object) - Optional - Information about the last user who updated the library - **avatar** (string) - Optional - Avatar URL of the user - **id** (integer) - Optional - User ID - **name** (string) - Optional - Username - **layerId** (string) - Optional - The layer ID the library belongs to - **name** (string) - Optional - The name of the library - **pageInfo** (object) - Optional - Information about the library's page - **backgroundColor** (string) - Optional - Background color of the page - **frameName** (string) - Optional - Frame name - **layerId** (string) - Optional - Layer ID - **pageId** (string) - Optional - Page ID - **pageName** (string) - Optional - Page name - **ukey** (string) - Optional - The unique UKey of the library - **updatedAt** (string) - Optional - The update time of the library - **meta** (object) - Optional - Metadata about the response - **time** (integer) - Optional - Response time - **trace** (string) - Optional - Trace ID for debugging - **msg** (string) - Optional - Message indicating the status of the response #### Response Example ```json { "code": "string", "data": [ { "cover": "string", "createdAt": "string", "description": "string", "documentId": 0, "lastUpdator": { "avatar": "string", "id": 0, "name": "string" }, "layerId": "string", "name": "string", "pageInfo": { "backgroundColor": "string", "frameName": "string", "layerId": "string", "pageId": "string", "pageName": "string" }, "ukey": "string", "updatedAt": "string" } ], "meta": { "time": 0, "trace": "string" }, "msg": "string" } ``` ``` -------------------------------- ### Get or Set SectionNode Name Source: https://developers.mastergo.com/apis/sectionNode.html Reads or sets the name of the SectionNode, which is displayed in the layer panel. ```typescript name: string ``` -------------------------------- ### Get Attached Connectors Source: https://developers.mastergo.com/apis/sectionNode.html Returns an array of connector nodes attached to this node. ```typescript attachedConnectors: ConnectorNode[] ``` -------------------------------- ### Get Team Library Source: https://developers.mastergo.com/rest-api Retrieves a list of component sets, components, and styles within a team library. This endpoint provides detailed information about each item, including its metadata, creator, and update history. ```APIDOC ## GET /websites/developers_mastergo/teamLibrary ### Description Retrieves a list of component sets, components, and styles within a team library. This endpoint provides detailed information about each item, including its metadata, creator, and update history. ### Method GET ### Endpoint /websites/developers_mastergo/teamLibrary ### Response #### Success Response (200) - **code** (string) - OK or error code - **data** (object) - Contains the team library information. - **teamLibrary** (array) - List of team libraries. - **componentSets** (array) - List of component sets within a team library. - **cover** (string) - Component set cover image URL. - **createdAt** (string) - Timestamp of component set creation. - **description** (string) - Description of the component set. - **documentId** (integer) - ID of the document the component set belongs to. - **lastUpdator** (object) - Information about the last user who updated the component set. - **avatar** (string) - Avatar URL of the last updator. - **id** (integer) - ID of the last updator. - **name** (string) - Name of the last updator. - **layerId** (string) - ID of the layer the component set belongs to. - **name** (string) - Name of the component set. - **pageInfo** (object) - Information about the page where the component set is located. - **backgroundColor** (string) - Background color of the page. - **frameName** (string) - Name of the frame on the page. - **layerId** (string) - ID of the layer on the page. - **pageId** (string) - ID of the page. - **pageName** (string) - Name of the page. - **ukey** (string) - Unique key of the component set. - **updatedAt** (string) - Timestamp of the last update to the component set. - **components** (array) - List of components within a team library. - **componentSetUkey** (string) - Unique key of the component set the component belongs to. - **cover** (string) - Component cover image URL. - **createdAt** (string) - Timestamp of component creation. - **description** (string) - Description of the component. - **documentId** (integer) - ID of the document the component belongs to. - **height** (number) - Height of the component. - **lastUpdator** (object) - Information about the last user who updated the component. - **avatar** (string) - Avatar URL of the last updator. - **id** (integer) - ID of the last updator. - **name** (string) - Name of the last updator. - **layerId** (string) - ID of the layer the component belongs to. - **name** (string) - Name of the component. - **pageInfo** (object) - Information about the page where the component is located. - **backgroundColor** (string) - Background color of the page. - **frameName** (string) - Name of the frame on the page. - **layerId** (string) - ID of the layer on the page. - **pageId** (string) - ID of the page. - **pageName** (string) - Name of the page. - **type** (string) - Type of the component. - **ukey** (string) - Unique key of the component. - **updatedAt** (string) - Timestamp of the last update to the component. - **width** (number) - Width of the component. - **createdAt** (string) - Timestamp of team library creation. - **creator** (object) - Information about the user who created the team library. - **avatar** (string) - Avatar URL of the creator. - **id** (integer) - ID of the creator. - **name** (string) - Name of the creator. - **documentId** (integer) - ID of the document the team library belongs to. - **documentName** (string) - Name of the document the team library belongs to. - **id** (string) - Unique ID of the team library. - **projectId** (integer) - ID of the project the team library belongs to. - **publishedScope** (string) - Scope of the team library publication. - **styles** (array) - List of styles within a team library. - **cover** (string) - Style cover image URL. - **createdAt** (string) - Timestamp of style creation. - **description** (string) - Description of the style. - **documentId** (integer) - ID of the document the style belongs to. - **lastUpdator** (object) - Information about the last user who updated the style. - **avatar** (string) - Avatar URL of the last updator. - **id** (integer) - ID of the last updator. - **name** (string) - Name of the last updator. - **name** (string) - Name of the style. - **sortIndex** (string) - Sort index for the style. - **styleSubType** (integer) - Subtype of the style. - **styleType** (string) - Type of the style. - **ukey** (string) - Unique key of the style. - **updatedAt** (string) - Timestamp of the last update to the style. - **teamId** (integer) - ID of the team the team library belongs to. - **updatedAt** (string) - Timestamp of the last update to the team library. - **meta** (object) - Metadata for the response. - **time** (integer) - Processing time in milliseconds. - **msg** (string) - Message indicating the status of the request. ``` -------------------------------- ### Find Nodes by Criteria Source: https://developers.mastergo.com/apis/sectionNode.html Finds all descendant nodes whose types match the specified criteria. For example, to find all 'FRAME' and 'COMPONENT' nodes. ```typescript findAllWithCriteria(criteria: { types: T }): Array<{ type: T[number] } & SceneNode> // Example usage: const nodes = node.findAllWithCriteria({types: ['FRAME', 'COMPONENT']}) ``` -------------------------------- ### Get Parent of SectionNode Source: https://developers.mastergo.com/apis/sectionNode.html Retrieves the parent node of the current SectionNode. ```typescript parent: (BaseNode & ChildrenMixin) | void ``` -------------------------------- ### GET /openapi/v1/team/:teamId/components Source: https://developers.mastergo.com/rest-api Retrieves detailed information about all published components within a specified team. This endpoint is useful for fetching a comprehensive list of components available in a team's library. ```APIDOC ## GET /openapi/v1/team/:teamId/components ### Description Retrieves detailed information about all published components within a specified team. This endpoint is useful for fetching a comprehensive list of components available in a team's library. ### Method GET ### Endpoint /openapi/v1/team/:teamId/components ### Headers - **X-MG-Authentication** (string) - Required - OPENAPI authentication header ### Parameters #### Path Parameters - **teamId** (string) - Required - The ID of the team #### Response #### Success Response (200) - **code** (string) - OK if the request was successful - **data** (array) - An array of component objects - **componentSetUkey** (string) - Optional - The UKey of the component set the component belongs to - **cover** (string) - Optional - The cover image of the component - **createdAt** (string) - Optional - The creation time of the component - **description** (string) - Optional - The description of the component - **documentId** (integer) - Optional - The ID of the document the component belongs to - **height** (number) - Optional - The height of the component - **lastUpdator** (object) - Optional - Information about the last user who updated the component - **avatar** (string) - Optional - Avatar URL of the user - **id** (integer) - Optional - User ID - **name** (string) - Optional - Username - **layerId** (string) - Optional - The layer ID the component belongs to - **name** (string) - Optional - The name of the component - **pageInfo** (object) - Optional - Information about the component's page - **backgroundColor** (string) - Optional - Background color of the page - **frameName** (string) - Optional - Frame name - **layerId** (string) - Optional - Layer ID - **pageId** (string) - Optional - Page ID - **pageName** (string) - Optional - Page name - **type** (string) - Optional - The type of the component - **ukey** (string) - Optional - The unique UKey of the component - **updatedAt** (string) - Optional - The update time of the component - **width** (number) - Optional - The width of the component - **meta** (object) - Optional - Metadata about the response - **time** (integer) - Optional - Response time - **trace** (string) - Optional - Trace ID for debugging - **msg** (string) - Optional - Message indicating the status of the response #### Response Example ```json { "code": "string", "data": [ { "componentSetUkey": "string", "cover": "string", "createdAt": "string", "description": "string", "documentId": 0, "height": 0.0, "lastUpdator": { "avatar": "string", "id": 0, "name": "string" }, "layerId": "string", "name": "string", "pageInfo": { "backgroundColor": "string", "frameName": "string", "layerId": "string", "pageId": "string", "pageName": "string" }, "type": "string", "ukey": "string", "updatedAt": "string", "width": 0.0 } ], "meta": { "time": 0, "trace": "string" }, "msg": "string" } ``` ``` -------------------------------- ### Get Enterprise Member Details Source: https://developers.mastergo.com/rest-api Retrieves detailed information about enterprise members, with options for filtering by team, status, roles, and seats. ```APIDOC ## POST /openapi/v1/team-users ### Description Retrieves detailed information about enterprise members, with options for filtering by team, status, roles, and seats. ### Method POST ### Endpoint /openapi/v1/team-users ### Parameters #### Request Headers - **X-MG-Authentication** (string) - Required - OPENAPI authentication header #### Request Body - **no_team** (boolean) - Optional - Do not query team information. - **team_id** (integer) - Optional - The team ID. - **page_no** (integer) - Optional - Page number, starting from 1. - **page_size** (integer) - Optional - Number of items per page. - **keyword** (string) - Optional - Keyword search, supports searching by username, email, and organization structure. - **user_status** (array) - Optional - User status (0: normal, 1: disabled). - **roles** (array) - Optional - Roles (owner, admin, member, guest). - **jobs** (array) - Optional - Job titles (manager, producter, ui, graphic, ux, developer, qa, operator, freelancer, student, other). - **seats** (array) - Optional - Seats, supports searching by multiple seats separated by commas. - **sort** (string) - Optional - Sorting field (name, job, role, seat, timeActivity, joinTime). - **with_last_edit_time** (boolean) - Optional - Whether to return the last edit time (private deployment only). ``` -------------------------------- ### Find All Nodes in SectionNode Subtree Source: https://developers.mastergo.com/apis/sectionNode.html Searches the entire subtree starting from the current SectionNode, applying a callback to each node and returning all nodes for which the callback returns true. ```typescript findAll(callback?: (node: SceneNode) => boolean): ReadonlyArray ``` -------------------------------- ### Get Plugin Data from SectionNode Source: https://developers.mastergo.com/apis/sectionNode.html Retrieves custom information stored on the node, private to your plugin. Decode values using JSON.parse if they are not strings. ```typescript getPluginData(key: string): string ``` -------------------------------- ### GET /openapi/v1/document/:documentId/componentSets Source: https://developers.mastergo.com/rest-api Retrieves a list of all published component sets within a specified document. This endpoint is useful for developers who need to access all component sets that have been published to the team library from a particular document. ```APIDOC ## GET /openapi/v1/document/:documentId/componentSets ### Description Retrieves a list of all published component sets within a specified document. This endpoint is useful for developers who need to access all component sets that have been published to the team library from a particular document. ### Method GET ### Endpoint /openapi/v1/document/:documentId/componentSets ### Parameters #### Path Parameters - **documentId** (string) - Required - The ID of the file. #### Request Body None ### Response #### Success Response (200) - **code** (string) - OK if successful, error code otherwise. - **data** (object) - Contains the list of component sets. - **componentSetUkey** (string) - The unique key of the component set. - **cover** (string) - Component set cover. - **createdAt** (string) - Component set creation time. - **description** (string) - Component set description. - **documentId** (integer) - The ID of the document the component set belongs to. - **height** (number) - Component height. - **lastUpdator** (object) - Information about the last person to update the component set. - **avatar** (string) - User avatar. - **id** (integer) - User ID. - **name** (string) - User name. - **layerId** (string) - The ID of the layer the component set belongs to. - **name** (string) - Component set name. - **pageInfo** (object) - Information about the component set's page. - **backgroundColor** (string) - Background color. - **frameName** (string) - Container name. - **layerId** (string) - Layer ID. - **pageId** (string) - Page ID. - **pageName** (string) - Page name. - **type** (string) - Component set type. - **ukey** (string) - The unique key of the component set. - **updatedAt** (string) - Component set update time. - **width** (number) - Component width. - **meta** (object) - Metadata for the response. - **time** (integer) - Processing time. - **trace** (string) - Trace ID for troubleshooting. - **msg** (string) - Message indicating the status of the operation. #### Response Example ```json { "code": "string", "data": { "componentSetUkey": "string", "cover": "string", "createdAt": "string", "description": "string", "documentId": 0, "height": 0.0, "lastUpdator": { "avatar": "string", "id": 0, "name": "string" }, "layerId": "string", "name": "string", "pageInfo": { "backgroundColor": "string", "frameName": "string", "layerId": "string", "pageId": "string", "pageName": "string" }, "type": "string", "ukey": "string", "updatedAt": "string", "width": 0.0 }, "meta": { "time": 0, "trace": "string" }, "msg": "string" } ``` ``` -------------------------------- ### Get SectionNode Children Source: https://developers.mastergo.com/apis/sectionNode.html Retrieves a read-only array of the direct child nodes of the current SectionNode. ```typescript children: ReadonlyArray ``` -------------------------------- ### Find One Node in SectionNode Subtree Source: https://developers.mastergo.com/apis/sectionNode.html Searches the entire node tree starting from the current SectionNode, applying a callback to each node and returning the first node for which the callback returns true. ```typescript findOne(callback: (node: SceneNode) => boolean): SceneNode | null ``` -------------------------------- ### Configure Enterprise Auto-Start Plugin Response Source: https://developers.mastergo.com/rest-api Response for configuring enterprise auto-start plugins. A null data field indicates a successful configuration. ```json { "code": "string", "data": null, "meta": { "time": 0, "trace": "string" }, "msg": "string" } ``` -------------------------------- ### ComponentNode Instance Creation Source: https://developers.mastergo.com/apis/componentNode.html Details on how to create an instance of a component node. ```APIDOC ## ComponentNode Instance Creation ### `createInstance` * Type: `() => InstanceNode` Creates an instance of this component. By default, `mg.document.currentPage` will be the parent of the newly created instance. ``` -------------------------------- ### Configure Organization Auto-Start Plugins Source: https://developers.mastergo.com/rest-api Configures which plugins should auto-start for the organization, for both design and development modes. ```APIDOC ## PUT /openapi/v1/plugin/org/settings ### Description Configures which plugins should auto-start for the organization, for both design and development modes. ### Method PUT ### Endpoint /openapi/v1/plugin/org/settings ### Parameters #### Request Headers - **X-MG-Authentication** (string) - Required - OPENAPI authentication header #### Request Body - **pluginSettings** (object) - Plugin auto-start configuration. Requires at least one of canvas or devMode. - **canvas** (object) - Design mode plugin auto-start configuration - **plugin** (string) - Optional - Plugin ID - **pluginApply** (integer) - Required - Application scope (1 for organization level) - **pluginAuto** (boolean) - Optional - Auto-start switch (true to enable, false to disable) - **pluginEnableClose** (integer) - Required - Force start (1 for yes, 2 for no) - **devMode** (object) - Development mode plugin auto-start configuration - **plugin** (string) - Optional - Plugin ID - **pluginApply** (integer) - Required - Application scope (1 for organization level) - **pluginAuto** (boolean) - Optional - Auto-start switch (true to enable, false to disable) - **pluginEnableClose** (integer) - Required - Force start (1 for yes, 2 for no) ### Response #### Success Response (200) - **code** (string) - Response code, OK for success, error code otherwise - **data** (null) - Response data is null on success - **meta** (object) - Metadata - **time** (integer) - Timestamp - **trace** (string) - Trace ID for troubleshooting - **msg** (string) - Response message ``` -------------------------------- ### Set and Clear Documentation Links for a Component Source: https://developers.mastergo.com/apis/componentNode.html Demonstrates how to set a single documentation link for a component node and how to clear all documentation links by setting the property to an empty array. ```typescript node.documentationLinks = [{ uri: "https://mastergo.com" }] // clear documentation links node.documentationLinks = [] ``` -------------------------------- ### Component Set Response (200 OK) Source: https://developers.mastergo.com/rest-api This JSON structure outlines a successful response for fetching component set details. It contains information about the component set's properties, creation, and associated page. ```json { "code": "string", "data": { "cover": "string", "createdAt": "string", "description": "string", "documentId": 0, "lastUpdator": { "avatar": "string", "id": 0, "name": "string" }, "layerId": "string", "name": "string", "pageInfo": { "backgroundColor": "string", "frameName": "string", "layerId": "string", "pageId": "string", "pageName": "string" }, "ukey": "string", "updatedAt": "string" }, "meta": { "time": 0, "trace": "string" }, "msg": "string" } ``` -------------------------------- ### ComponentNode Base Properties and Methods Source: https://developers.mastergo.com/apis/componentNode.html Provides details on the fundamental properties and methods of a ComponentNode, including its type, cloning, ID, removal, parent access, name manipulation, and plugin data management. ```APIDOC ## ComponentNode Base Properties and Methods ### `type` * Readonly: `true` * Type: `'COMPONENT'` Node type, for `ComponentNode` nodes, the value is the string `'COMPONENT'`. ### `clone` * Type: `clone(): ComponentNode` Clones the component node into a new component node without instances. By default, the parent of the new node is `mg.document.currentPage`. ### `id` * Readonly: `true` * Type: `string` The ID of the `ComponentNode`. ### `remove` * Type: `remove():void` Removes the current node from its `parent` node. ### `removed` * Type: `boolean` Returns `true` if the node has been removed. If the plugin remains running and holds a reference to a node, you should always check the node's `removed` property before operating on it to ensure it has not been removed. ### `parent` * Readonly: `true` * Type: `(BaseNode & ChildrenMixin) | void` Gets the parent node of the current node. ### `name` * Type: `string` Reads or sets the component's name, which is the layer name displayed in the layer panel. ### `getPluginData` * Type: `getPluginData(key: string): string` Retrieves custom information stored on the node, private to your plugin. To get value types other than strings, decode them first using `JSON.parse`. ### `setPluginData` * Type: `setPluginData(key: string, value: string): void` Allows you to store custom information on any node, private to your plugin. To store value types other than strings, encode them first using `JSON.stringify`. ### `getPluginDataKeys` * Type: `getPluginDataKeys(): string[]` Gets all the keys for custom information stored by the current plugin. ### `removePluginData` * Type: `removePluginData(key: string): void` Removes custom information stored by the current plugin. ### `clearPluginData` * Type: `clearPluginData(): void` Clears all custom information stored by the current plugin. ### `getSharedPluginData` * Type: `getSharedPluginData(namespace: string, key: string): string` Retrieves shared data stored on a specific namespace. ### `setSharedPluginData` * Type: `setSharedPluginData(namespace: string, key: string, value: string): void` This allows you to store custom information on any node. You can later retrieve it by calling `getSharedPluginData` with the same namespace and key. To find all data on a node stored within a specific namespace, use `getSharedPluginDataKeys`. Any data you write using this API can be read by any plugin. The intention is to allow plugins to interoperate. If you do not want other plugins to be able to read your data, use `setPluginData` instead. You must also provide a `namespace` parameter to avoid key collisions with other plugins. This parameter is mandatory to prevent multiple plugins from using common key names (like `data`) and overwriting each other. We recommend passing a value that identifies your plugin. This namespace can be provided to authors of other plugins so they can read data from your plugin. WARNING `namespace` is a unique string used to identify your plugin and avoid key collisions with other plugins. The namespace must contain at least 3 alphanumeric characters. ### `getSharedPluginDataKeys` * Type: `getSharedPluginDataKeys(namespace: string): string[]` Finds the keys for all data stored on a node within a specific namespace. ### `removeSharedPluginData` * Type: `removeSharedPluginData(namespace: string, key: string): void` Removes custom information stored on a specific namespace. ### `clearSharedPluginData` * Type: `clearSharedPluginData(namespace: string): void` Clears all data stored on a specific namespace. WARNING Call this API with caution, as it may result in the loss of shared data being used by others. ``` -------------------------------- ### Component Response (200 OK) Source: https://developers.mastergo.com/rest-api This JSON structure represents a successful response when retrieving component details. It includes information about the component's properties, creation, and associated page. ```json { "code": "string", "data": { "componentSetUkey": "string", "cover": "string", "createdAt": "string", "description": "string", "documentId": 0, "height": 0.0, "lastUpdator": { "avatar": "string", "id": 0, "name": "string" }, "layerId": "string", "name": "string", "pageInfo": { "backgroundColor": "string", "frameName": "string", "layerId": "string", "pageId": "string", "pageName": "string" }, "type": "string", "ukey": "string", "updatedAt": "string", "width": 0.0 }, "meta": { "time": 0, "trace": "string" }, "msg": "string" } ``` -------------------------------- ### Handle Drop Events with getNodeByPosition Source: https://developers.mastergo.com/updates This snippet demonstrates how to handle drop events, find the target container node at specific coordinates, and create a new node from an SVG. It utilizes `mg.getNodeByPosition` to locate nodes and `mg.createNodeFromSvgAsync` for SVG conversion. ```typescript const containers = new Set<(SceneNode | PageNode)['type']>(['BOOLEAN_OPERATION','FRAME', 'COMPONENT', 'GROUP', 'PAGE']) mg.on('drop', (dropEvent: DropEvent) => { const {dropMetadata, absoluteX, absoluteY} = dropEvent; const currentPage = mg.document.currentPage; // 获取对应坐标的容器 let target = mg.getNodeByPosition({x: absoluteX, y: absoluteY}); while(target && !containers.has(target.type)){ target = target.parent; } const parent = target || currentPage; mg.createNodeFromSvgAsync(dropMetadata.svg) .then((frame) => { frame.x = absoluteX - frame.width / 2, frame.y = absoluteY - frame.height / 2, parent.appendChild(frame) mg.document.currentPage.selection = [frame] mg.commitUndo(); }) }) ```