Skip to content

Commit

Permalink
Merge pull request #32 from ArGup/main
Browse files Browse the repository at this point in the history
Updating docs to reflect removal of timer APIs and addition of certain new APIs
  • Loading branch information
hollyschinsky authored Nov 29, 2023
2 parents 5bc7832 + 8ef17ae commit 92739b5
Show file tree
Hide file tree
Showing 33 changed files with 3,032 additions and 1,998 deletions.
22 changes: 21 additions & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ module.exports = {
{
title: "EllipseNode",
path: "references/document-sandbox/document-apis/classes/EllipseNode.md",
},
},
{
title: "ExpressRootNode",
path: "references/document-sandbox/document-apis/classes/ExpressRootNode.md",
Expand Down Expand Up @@ -204,14 +204,30 @@ module.exports = {
title: "RectangleNode",
path: "references/document-sandbox/document-apis/classes/RectangleNode.md",
},
{
title: "RestrictedItemList",
path: "references/document-sandbox/document-apis/classes/RestrictedItemList.md",
},
{
title: "SolidColorShapeNode",
path: "references/document-sandbox/document-apis/classes/SolidColorShapeNode.md",
},
{
title: "StrokableNode",
path: "references/document-sandbox/document-apis/classes/StrokableNode.md",
},
{
title: "StrokeShapeNode",
path: "references/document-sandbox/document-apis/classes/StrokeShapeNode.md",
},
{
title: "TextNode",
path: "references/document-sandbox/document-apis/classes/TextNode.md",
},
{
title: "UnknownNode",
path: "references/document-sandbox/document-apis/classes/UnknownNode.md",
},
],
},
{
Expand Down Expand Up @@ -250,6 +266,10 @@ module.exports = {
title: "ListItem",
path: "references/document-sandbox/document-apis/interfaces/ListItem.md",
},
{
title: "Point",
path: "references/document-sandbox/document-apis/interfaces/Point.md",
},
{
title: "RectangleGeometry",
path: "references/document-sandbox/document-apis/interfaces/RectangleGeometry.md",
Expand Down
35 changes: 34 additions & 1 deletion src/pages/references/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,39 @@ contributors:

# Changelog

## 2023-11-28

### Updates

- The [Document API References](./document-sandbox/document-apis/) were updated with the following additions and changes:

**New Classes/Interfaces**<br/>

- New [RestrictedItemList class](./document-sandbox/document-apis/classes/RestrictedItemList.md)
- New [UnknownNode class](./document-sandbox/document-apis/classes/UnknownNode.md)
- New [SolidColorShapeNode class](./document-sandbox/document-apis/classes/SolidColorShapeNode.md)
- New [Point interface](./document-sandbox/document-apis/interfaces/Point.md)
- New `queueAsyncEdit` method added to the [Editor](./document-sandbox/document-apis/classes/Editor.md) class.

**Updates to Node Classes**<br/>

The accessors and methods below were removed or replaced with new names in the [`Node` class](./document-sandbox/document-apis/classes/Node.md) and classes that extend it. Please refer to the [Document API References](./document-sandbox/document-apis/) specifically to learn more about each.

- Removes `absoluteRotation` accessor
- Removes `absoluteTransform` accessor
- Removes `relativeRotation` accessor
- Removes `relativeTransform` accessor
- Removes `translateX` accessor
- Removes `translateY` accessor
- Adds `rotation` accessor
- Adds `rotationInScreen` accessor
- Adds `transformMatrix` accessor
- Adds `translation` accessor
- Adds `setPositionInParent` method
- Adds `setRotationInParent` method

- The [Web API's in the Document Sandbox Reference](./document-sandbox/web/index.md) were updated to remove the timer methods which are no longer supported (ie: `setTimeout()`, `clearTimeout` and `setInterval()`, `clearInterval`).

## 2023-11-27

Updated [Document API references](./document-sandbox/document-apis/) to include:
Expand Down Expand Up @@ -226,7 +259,7 @@ Added new code sample to demonstrate how to use SWC-React and set theme properti
- Auto reload of the add-on when a change is detected sometimes fails to work properly. This can result in changes to the UI HTML not being reflected, but can also cause the connection between the panel UI and the document sandbox to not be properly initialized (your UI may appear to be unresponsive as a result). If you encounter this situation, manually reloading the add-on from the developer panel will usually resolve the issue. We're working on a fix.
- It's occasionally possible to run into a race condition where the communications bridge between the two contexts (panel vs document sandbox) is not set up in time. If you interact with your panel UI immediately after it's reloaded, the click may appear do nothing instead of invoking your script code. We're working on a fix for this.
- Common pitfalls
- If you split your work on a document over multiple frames using `setTimeout`, be sure to protect against reentrancy, otherwise you may end up corrupting the user's undo stack. You should disable elements on the panel UI that could allow the user to execute your code before it is complete and then re-enable those elements when the code is done. The issue will be fixed in a future release.
- If you split your work on a document over multiple frames, be sure to protect against reentrancy, otherwise you may end up corrupting the user's undo stack. You should disable elements on the panel UI that could allow the user to execute your code before it is complete and then re-enable those elements when the code is done. The issue will be fixed in a future release.
- When setting up communication between your panel UI code and your script sandbox code, calling `apiProxy()` with the wrong argument will do nothing without providing any error feedback. If communication is not working, carefully double-check your UI code is requesting the `"script"` API proxy and your script sandbox code is requesting the `"panel"` API proxy.
- Unexpected behavior
- If the user has a selection and your add-on creates new content, the selection is cleared. This will be addressed before release. An API will be added in the future that will allow you to change the selection to content your add-on creates.
Expand Down
14 changes: 3 additions & 11 deletions src/pages/references/document-sandbox/communication/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ The document sandbox and iframe runtime are two different runtime execution envi
A default exported module from `AddOnScriptSdk` is provided to enable the communication between the iframe and the document sandbox via its' `instance.runtime` object. You can simply import the module into your script file code for use, and create a reference to the `runtime` object. For instance:

```js
// import addOnSandboxSdk from "add-on-sdk-document-sandbox" - TODOHS
import AddOnScriptSdk from "AddOnScriptSdk"; // AddOnScriptSdk is a default import

const { runtime } = AddOnScriptSdk.instance; // runtime object provides direct access to the comm methods
Expand All @@ -48,7 +47,6 @@ This example shows how to expose APIs from the document sandbox SDK (via `code.j
#### `code.js`

```js
// import addOnSandboxSdk from "add-on-sdk-document-sandbox" - TODOHS
import AddOnScriptSdk from "AddOnScriptSdk";

const { runtime } = AddOnScriptSdk.instance;
Expand Down Expand Up @@ -106,15 +104,11 @@ addOnUISdk.ready.then(async () => {
performWorkOnUI: function (data, someFlag) {
// Do some ui operation
},
getDataFromUI: async function () {
let resolver = undefined;

getDataFromUI: async function () {
const promise = new Promise((resolve) => {
resolver = resolve;
resolve("button_color_blue");
});
setTimeout(() => {
resolver("button_color_blue");
}, 10);

return await promise;
},
};
Expand All @@ -126,7 +120,6 @@ addOnUISdk.ready.then(async () => {
#### `code.js`

```js
// import addOnSandboxSdk from "add-on-sdk-document-sandbox" - TODOHS
import AddOnScriptSdk from "AddOnScriptSdk"; // default import

const { runtime } = AddOnScriptSdk.instance;
Expand All @@ -141,7 +134,6 @@ async function callUIApis() {
},
true
);


const result = await uiApis.getDataFromUI();
console.log("Data from UI: " + result);
Expand Down
Loading

0 comments on commit 92739b5

Please sign in to comment.