@adobe/create-ccweb-add-on 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/AddOnTemplateSelector.js +13 -13
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -5
- package/dist/templates/{javascript-with-script-runtime → javascript-with-document-sandbox}/template/README.md +1 -1
- package/{templates/javascript-with-script-runtime → dist/templates/javascript-with-document-sandbox}/template/src/code.js +10 -11
- package/dist/templates/{javascript-with-script-runtime → javascript-with-document-sandbox}/template/src/index.html +9 -6
- package/dist/templates/{javascript-with-script-runtime → javascript-with-document-sandbox}/template/src/manifest.json +1 -1
- package/dist/templates/react-javascript/template.json +7 -7
- package/dist/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template/README.md +1 -1
- package/{templates/react-javascript-with-script-runtime → dist/templates/react-javascript-with-document-sandbox}/template/src/index.html +5 -2
- package/dist/templates/{react-typescript-with-script-runtime → react-javascript-with-document-sandbox}/template/src/manifest.json +1 -1
- package/dist/templates/{react-javascript-with-script-runtime/template/src/script → react-javascript-with-document-sandbox/template/src/sandbox}/code.js +10 -11
- package/dist/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template/src/ui/components/App.jsx +2 -2
- package/{templates/react-javascript-with-script-runtime → dist/templates/react-javascript-with-document-sandbox}/template/src/ui/index.jsx +3 -3
- package/{templates/react-javascript-with-script-runtime → dist/templates/react-javascript-with-document-sandbox}/template/webpack.config.js +3 -3
- package/dist/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template.json +7 -7
- package/dist/templates/react-typescript/template/webpack.config.js +1 -1
- package/dist/templates/react-typescript/template.json +6 -6
- package/{templates/react-typescript-with-script-runtime → dist/templates/react-typescript-with-document-sandbox}/template/README.md +1 -1
- package/dist/templates/{react-javascript-with-script-runtime → react-typescript-with-document-sandbox}/template/src/index.html +5 -2
- package/dist/templates/{react-javascript-with-script-runtime → react-typescript-with-document-sandbox}/template/src/manifest.json +1 -1
- package/dist/templates/react-typescript-with-document-sandbox/template/src/models/DocumentSandboxApi.ts +4 -0
- package/dist/templates/react-typescript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +11 -0
- package/dist/templates/{typescript-with-script-runtime/template/src/script → react-typescript-with-document-sandbox/template/src/sandbox}/code.ts +12 -13
- package/dist/templates/{react-typescript-with-script-runtime/template/src/script → react-typescript-with-document-sandbox/template/src/sandbox}/tsconfig.json +1 -1
- package/{templates/react-typescript-with-script-runtime → dist/templates/react-typescript-with-document-sandbox}/template/src/ui/components/App.tsx +3 -3
- package/{templates/react-typescript-with-script-runtime → dist/templates/react-typescript-with-document-sandbox}/template/src/ui/index.tsx +5 -5
- package/{templates/react-typescript-with-script-runtime → dist/templates/react-typescript-with-document-sandbox}/template/webpack.config.js +7 -7
- package/dist/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template.json +6 -6
- package/dist/templates/typescript/template.json +5 -5
- package/{templates/typescript-with-script-runtime → dist/templates/typescript-with-document-sandbox}/template/README.md +1 -1
- package/{templates/typescript-with-script-runtime → dist/templates/typescript-with-document-sandbox}/template/src/index.html +5 -2
- package/dist/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/manifest.json +1 -1
- package/dist/templates/typescript-with-document-sandbox/template/src/models/DocumentSandboxApi.ts +4 -0
- package/dist/templates/typescript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +11 -0
- package/dist/templates/{react-typescript-with-script-runtime/template/src/script → typescript-with-document-sandbox/template/src/sandbox}/code.ts +12 -13
- package/{templates/typescript-with-script-runtime/template/src/script → dist/templates/typescript-with-document-sandbox/template/src/sandbox}/tsconfig.json +1 -1
- package/dist/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/ui/components/App.ts +5 -5
- package/{templates/typescript-with-script-runtime → dist/templates/typescript-with-document-sandbox}/template/webpack.config.js +6 -6
- package/dist/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template.json +5 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/app/AddOnTemplateSelector.ts +13 -13
- package/src/constants.ts +5 -5
- package/src/test/app/AddOnTemplateSelector.spec.ts +12 -12
- package/templates/{javascript-with-script-runtime → javascript-with-document-sandbox}/template/README.md +1 -1
- package/templates/{react-javascript-with-script-runtime/template/src/script → javascript-with-document-sandbox/template/src}/code.js +10 -11
- package/templates/{javascript-with-script-runtime → javascript-with-document-sandbox}/template/src/index.html +9 -6
- package/templates/javascript-with-document-sandbox/template/src/manifest.json +23 -0
- package/templates/react-javascript/template.json +7 -7
- package/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template/README.md +1 -1
- package/{dist/templates/react-typescript-with-script-runtime → templates/react-javascript-with-document-sandbox}/template/src/index.html +6 -3
- package/templates/react-javascript-with-document-sandbox/template/src/manifest.json +23 -0
- package/{dist/templates/javascript-with-script-runtime/template/src → templates/react-javascript-with-document-sandbox/template/src/sandbox}/code.js +10 -11
- package/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template/src/ui/components/App.jsx +2 -2
- package/{dist/templates/react-javascript-with-script-runtime → templates/react-javascript-with-document-sandbox}/template/src/ui/index.jsx +3 -3
- package/{dist/templates/react-javascript-with-script-runtime → templates/react-javascript-with-document-sandbox}/template/webpack.config.js +3 -3
- package/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template.json +7 -7
- package/templates/react-typescript/template/webpack.config.js +1 -1
- package/templates/react-typescript/template.json +6 -6
- package/{dist/templates/react-typescript-with-script-runtime → templates/react-typescript-with-document-sandbox}/template/README.md +1 -1
- package/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/src/index.html +6 -3
- package/templates/react-typescript-with-document-sandbox/template/src/manifest.json +23 -0
- package/templates/react-typescript-with-document-sandbox/template/src/models/DocumentSandboxApi.ts +4 -0
- package/templates/react-typescript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +11 -0
- package/templates/{typescript-with-script-runtime/template/src/script → react-typescript-with-document-sandbox/template/src/sandbox}/code.ts +12 -13
- package/{dist/templates/typescript-with-script-runtime/template/src/script → templates/react-typescript-with-document-sandbox/template/src/sandbox}/tsconfig.json +1 -1
- package/{dist/templates/react-typescript-with-script-runtime → templates/react-typescript-with-document-sandbox}/template/src/ui/components/App.tsx +3 -3
- package/{dist/templates/react-typescript-with-script-runtime → templates/react-typescript-with-document-sandbox}/template/src/ui/index.tsx +5 -5
- package/{dist/templates/react-typescript-with-script-runtime → templates/react-typescript-with-document-sandbox}/template/webpack.config.js +7 -7
- package/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template.json +6 -6
- package/templates/typescript/template.json +5 -5
- package/{dist/templates/typescript-with-script-runtime → templates/typescript-with-document-sandbox}/template/README.md +1 -1
- package/{dist/templates/typescript-with-script-runtime → templates/typescript-with-document-sandbox}/template/src/index.html +5 -2
- package/templates/typescript-with-document-sandbox/template/src/manifest.json +23 -0
- package/templates/typescript-with-document-sandbox/template/src/models/DocumentSandboxApi.ts +4 -0
- package/templates/typescript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +11 -0
- package/templates/{react-typescript-with-script-runtime/template/src/script → typescript-with-document-sandbox/template/src/sandbox}/code.ts +12 -13
- package/templates/{react-typescript-with-script-runtime/template/src/script → typescript-with-document-sandbox/template/src/sandbox}/tsconfig.json +1 -1
- package/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/ui/components/App.ts +5 -5
- package/{dist/templates/typescript-with-script-runtime → templates/typescript-with-document-sandbox}/template/webpack.config.js +6 -6
- package/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template.json +5 -5
- package/dist/templates/react-typescript-with-script-runtime/template/src/models/ScriptApi.ts +0 -3
- package/dist/templates/react-typescript-with-script-runtime/template/src/script/add-on-script-sdk.d.ts +0 -11
- package/dist/templates/typescript-with-script-runtime/template/src/models/ScriptApi.ts +0 -3
- package/dist/templates/typescript-with-script-runtime/template/src/script/add-on-script-sdk.d.ts +0 -11
- package/templates/javascript-with-script-runtime/template/src/manifest.json +0 -23
- package/templates/react-javascript-with-script-runtime/template/src/manifest.json +0 -23
- package/templates/react-typescript-with-script-runtime/template/src/manifest.json +0 -23
- package/templates/react-typescript-with-script-runtime/template/src/models/ScriptApi.ts +0 -3
- package/templates/react-typescript-with-script-runtime/template/src/script/add-on-script-sdk.d.ts +0 -11
- package/templates/typescript-with-script-runtime/template/src/manifest.json +0 -23
- package/templates/typescript-with-script-runtime/template/src/models/ScriptApi.ts +0 -3
- package/templates/typescript-with-script-runtime/template/src/script/add-on-script-sdk.d.ts +0 -11
- /package/dist/templates/{javascript-with-script-runtime → javascript-with-document-sandbox}/template/gitignore +0 -0
- /package/dist/templates/{javascript-with-script-runtime → javascript-with-document-sandbox}/template.json +0 -0
- /package/dist/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template/.babelrc +0 -0
- /package/dist/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template/gitignore +0 -0
- /package/dist/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template/src/ui/components/App.css +0 -0
- /package/dist/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/gitignore +0 -0
- /package/dist/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/src/ui/add-on-ui-sdk.d.ts +0 -0
- /package/dist/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/src/ui/components/App.css +0 -0
- /package/dist/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/src/ui/tsconfig.json +0 -0
- /package/dist/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/tsconfig.json +0 -0
- /package/dist/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/gitignore +0 -0
- /package/dist/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/ui/add-on-ui-sdk.d.ts +0 -0
- /package/dist/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/ui/components/App.css.ts +0 -0
- /package/dist/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/ui/index.ts +0 -0
- /package/dist/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/ui/tsconfig.json +0 -0
- /package/dist/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/tsconfig.json +0 -0
- /package/templates/{javascript-with-script-runtime → javascript-with-document-sandbox}/template/gitignore +0 -0
- /package/templates/{javascript-with-script-runtime → javascript-with-document-sandbox}/template.json +0 -0
- /package/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template/.babelrc +0 -0
- /package/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template/gitignore +0 -0
- /package/templates/{react-javascript-with-script-runtime → react-javascript-with-document-sandbox}/template/src/ui/components/App.css +0 -0
- /package/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/gitignore +0 -0
- /package/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/src/ui/add-on-ui-sdk.d.ts +0 -0
- /package/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/src/ui/components/App.css +0 -0
- /package/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/src/ui/tsconfig.json +0 -0
- /package/templates/{react-typescript-with-script-runtime → react-typescript-with-document-sandbox}/template/tsconfig.json +0 -0
- /package/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/gitignore +0 -0
- /package/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/ui/add-on-ui-sdk.d.ts +0 -0
- /package/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/ui/components/App.css.ts +0 -0
- /package/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/ui/index.ts +0 -0
- /package/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/src/ui/tsconfig.json +0 -0
- /package/templates/{typescript-with-script-runtime → typescript-with-document-sandbox}/template/tsconfig.json +0 -0
|
@@ -36,7 +36,7 @@ import { stubInterface } from "ts-sinon";
|
|
|
36
36
|
import { AnalyticsErrorMarkers } from "../../AnalyticsMarkers.js";
|
|
37
37
|
import { AddOnTemplateSelector } from "../../app/AddOnTemplateSelector.js";
|
|
38
38
|
import type { TemplateSelector } from "../../app/TemplateSelector.js";
|
|
39
|
-
import { ADD_ON_TEMPLATES, PROGRAM_NAME } from "../../constants.js";
|
|
39
|
+
import { ADD_ON_TEMPLATES, PROGRAM_NAME, WITH_DOCUMENT_SANDBOX } from "../../constants.js";
|
|
40
40
|
import { CLIOptions } from "../../models/index.js";
|
|
41
41
|
|
|
42
42
|
describe("AddOnTemplateSelector", () => {
|
|
@@ -159,7 +159,7 @@ describe("AddOnTemplateSelector", () => {
|
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
it("should ask the user to select template name if an invalid templateName is present in CLIOptions.", async () => {
|
|
162
|
-
const
|
|
162
|
+
const documentSandboxChoices = [
|
|
163
163
|
{
|
|
164
164
|
title: "No",
|
|
165
165
|
value: false
|
|
@@ -173,7 +173,7 @@ describe("AddOnTemplateSelector", () => {
|
|
|
173
173
|
const promptsStub = sandbox.stub(prompts, "prompt");
|
|
174
174
|
promptsStub.resolves({
|
|
175
175
|
selectedTemplate: templateChoices[1].value,
|
|
176
|
-
|
|
176
|
+
includeDocumentSandbox: documentSandboxChoices[0].value
|
|
177
177
|
});
|
|
178
178
|
|
|
179
179
|
const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", "incorrect-template", false);
|
|
@@ -183,12 +183,12 @@ describe("AddOnTemplateSelector", () => {
|
|
|
183
183
|
|
|
184
184
|
assert.equal(template, templateChoices[1].value);
|
|
185
185
|
assert.equal(logger.warning.callCount, 1);
|
|
186
|
-
assert.equal(logger.warning.calledWith("You have chosen an invalid template", { prefix: "\n" }), true);
|
|
186
|
+
assert.equal(logger.warning.calledWith("You have chosen an invalid template.", { prefix: "\n" }), true);
|
|
187
187
|
assert.equal(analyticsService.postEvent.callCount, 0);
|
|
188
188
|
});
|
|
189
189
|
|
|
190
190
|
it("should prompt the user to select template if not present in CLIOptions.", async () => {
|
|
191
|
-
const
|
|
191
|
+
const documentSandboxChoices = [
|
|
192
192
|
{
|
|
193
193
|
title: "No",
|
|
194
194
|
value: false
|
|
@@ -202,7 +202,7 @@ describe("AddOnTemplateSelector", () => {
|
|
|
202
202
|
const promptsStub = sandbox.stub(prompts, "prompt");
|
|
203
203
|
promptsStub.resolves({
|
|
204
204
|
selectedTemplate: templateChoices[1].value,
|
|
205
|
-
|
|
205
|
+
includeDocumentSandbox: documentSandboxChoices[0].value
|
|
206
206
|
});
|
|
207
207
|
|
|
208
208
|
const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", "", false);
|
|
@@ -214,8 +214,8 @@ describe("AddOnTemplateSelector", () => {
|
|
|
214
214
|
assert.equal(analyticsService.postEvent.callCount, 0);
|
|
215
215
|
});
|
|
216
216
|
|
|
217
|
-
it("should return the template name when
|
|
218
|
-
const
|
|
217
|
+
it("should return the template name when document sandbox is included.", async () => {
|
|
218
|
+
const documentSandboxChoices = [
|
|
219
219
|
{
|
|
220
220
|
title: "No",
|
|
221
221
|
value: false
|
|
@@ -229,7 +229,7 @@ describe("AddOnTemplateSelector", () => {
|
|
|
229
229
|
const promptsStub = sandbox.stub(prompts, "prompt");
|
|
230
230
|
promptsStub.resolves({
|
|
231
231
|
selectedTemplate: templateChoices[1].value,
|
|
232
|
-
|
|
232
|
+
includeDocumentSandbox: documentSandboxChoices[1].value
|
|
233
233
|
});
|
|
234
234
|
|
|
235
235
|
const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", "", false);
|
|
@@ -238,7 +238,7 @@ describe("AddOnTemplateSelector", () => {
|
|
|
238
238
|
const template = await templateSelector.setupTemplate(cliOptions);
|
|
239
239
|
|
|
240
240
|
assert.equal(logger.warning.callCount, 0);
|
|
241
|
-
assert.equal(template, templateChoices[1].value +
|
|
241
|
+
assert.equal(template, templateChoices[1].value + `-${WITH_DOCUMENT_SANDBOX}`);
|
|
242
242
|
assert.equal(analyticsService.postEvent.callCount, 0);
|
|
243
243
|
});
|
|
244
244
|
|
|
@@ -257,10 +257,10 @@ describe("AddOnTemplateSelector", () => {
|
|
|
257
257
|
assert.equal(analyticsService.postEvent.callCount, 0);
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
-
it("should exit if user doesnt select any option in
|
|
260
|
+
it("should exit if user doesnt select any option in document sandbox prompt.", async () => {
|
|
261
261
|
const promptsStub = sandbox.stub(prompts, "prompt");
|
|
262
262
|
const exitProcessStub = sandbox.stub(process, "exit");
|
|
263
|
-
promptsStub.resolves({ selectedTemplate: templateChoices[1].value,
|
|
263
|
+
promptsStub.resolves({ selectedTemplate: templateChoices[1].value, includeDocumentSandbox: undefined });
|
|
264
264
|
|
|
265
265
|
const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", "", false);
|
|
266
266
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## About
|
|
2
2
|
|
|
3
|
-
This project has been created with _@adobe/create-ccweb-add-on_. As an example, this Add-on demonstrates how to get started with Add-on development using JavaScript with
|
|
3
|
+
This project has been created with _@adobe/create-ccweb-add-on_. As an example, this Add-on demonstrates how to get started with Add-on development using JavaScript with Document Sandbox Runtime.
|
|
4
4
|
|
|
5
5
|
## Tools
|
|
6
6
|
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { editor, utils } from "express";
|
|
1
|
+
import addOnSandboxSdk from "add-on-sdk-document-sandbox";
|
|
2
|
+
import { editor, utils } from "express-document-sdk";
|
|
3
3
|
|
|
4
|
-
// Get the
|
|
5
|
-
const { runtime } =
|
|
4
|
+
// Get the document sandbox runtime.
|
|
5
|
+
const { runtime } = addOnSandboxSdk.instance;
|
|
6
6
|
|
|
7
7
|
function start() {
|
|
8
8
|
// APIs to be exposed to the UI runtime
|
|
9
9
|
// i.e., to the `index.html` file of this add-on.
|
|
10
|
-
const
|
|
10
|
+
const sandboxApi = {
|
|
11
11
|
createRectangle: () => {
|
|
12
12
|
const rectangle = editor.createRectangle();
|
|
13
13
|
|
|
14
14
|
// Define rectangle dimensions.
|
|
15
|
-
rectangle.width =
|
|
16
|
-
rectangle.height =
|
|
15
|
+
rectangle.width = 240;
|
|
16
|
+
rectangle.height = 180;
|
|
17
17
|
|
|
18
18
|
// Define rectangle position.
|
|
19
|
-
rectangle.
|
|
20
|
-
rectangle.translateY = 100;
|
|
19
|
+
rectangle.translation = { x: 10, y: 10 };
|
|
21
20
|
|
|
22
21
|
// Define rectangle color.
|
|
23
22
|
const [red, green, blue, alpha] = [0.32, 0.34, 0.89, 1];
|
|
@@ -32,8 +31,8 @@ function start() {
|
|
|
32
31
|
}
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
// Expose `
|
|
36
|
-
runtime.exposeApi(
|
|
34
|
+
// Expose `sandboxApi` to the UI runtime.
|
|
35
|
+
runtime.exposeApi(sandboxApi);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
start();
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
-
<meta
|
|
6
|
-
|
|
5
|
+
<meta
|
|
6
|
+
name="description"
|
|
7
|
+
content="Get started with Add-on development using JavaScript with Document Sandbox Runtime"
|
|
8
|
+
/>
|
|
9
|
+
<meta name="keywords" content="Adobe, Express, Add-On, JavaScript, Document Sandbox Runtime" />
|
|
7
10
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
11
|
<title>Get Started</title>
|
|
9
12
|
<style>
|
|
@@ -53,18 +56,18 @@
|
|
|
53
56
|
const { runtime } = addOnUISdk.instance;
|
|
54
57
|
|
|
55
58
|
// Get the proxy object, which is required
|
|
56
|
-
// to call the APIs defined in the
|
|
59
|
+
// to call the APIs defined in the Document Sandbox runtime
|
|
57
60
|
// i.e., in the `code.js` file of this add-on.
|
|
58
|
-
const
|
|
61
|
+
const sandboxProxy = await runtime.apiProxy("documentSandbox");
|
|
59
62
|
|
|
60
63
|
const createRectangleButton = document.getElementById("createRectangle");
|
|
61
64
|
createRectangleButton.addEventListener("click", async event => {
|
|
62
|
-
await
|
|
65
|
+
await sandboxProxy.createRectangle();
|
|
63
66
|
});
|
|
64
67
|
|
|
65
68
|
// Enable the button only when:
|
|
66
69
|
// 1. `addOnUISdk` is ready,
|
|
67
|
-
// 2. `
|
|
70
|
+
// 2. `sandboxProxy` is available, and
|
|
68
71
|
// 3. `click` event listener is registered.
|
|
69
72
|
createRectangleButton.disabled = false;
|
|
70
73
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"testId": "",
|
|
3
|
+
"name": "",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"manifestVersion": 2,
|
|
6
|
+
"requirements": {
|
|
7
|
+
"apps": [
|
|
8
|
+
{
|
|
9
|
+
"name": "Express",
|
|
10
|
+
"apiVersion": 1
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"experimentalApis": true
|
|
14
|
+
},
|
|
15
|
+
"entryPoints": [
|
|
16
|
+
{
|
|
17
|
+
"type": "panel",
|
|
18
|
+
"id": "panel1",
|
|
19
|
+
"main": "index.html",
|
|
20
|
+
"documentSandbox": "code.js"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -6,22 +6,22 @@
|
|
|
6
6
|
"package": "ccweb-add-on-scripts package --use webpack"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@spectrum-web-components/theme": "0.
|
|
10
|
-
"@swc-react/button": "0.
|
|
11
|
-
"@swc-react/theme": "0.
|
|
9
|
+
"@spectrum-web-components/theme": "0.40.0",
|
|
10
|
+
"@swc-react/button": "0.40.0",
|
|
11
|
+
"@swc-react/theme": "0.40.0",
|
|
12
12
|
"react-dom": "18.2.0",
|
|
13
13
|
"react": "18.2.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@babel/core": "7.
|
|
17
|
-
"@babel/preset-env": "7.
|
|
18
|
-
"@babel/preset-react": "7.
|
|
16
|
+
"@babel/core": "7.23.3",
|
|
17
|
+
"@babel/preset-env": "7.23.3",
|
|
18
|
+
"@babel/preset-react": "7.23.3",
|
|
19
19
|
"babel-loader": "9.1.3",
|
|
20
20
|
"copy-webpack-plugin": "11.0.0",
|
|
21
21
|
"css-loader": "6.8.1",
|
|
22
22
|
"html-webpack-plugin": "5.5.3",
|
|
23
23
|
"style-loader": "3.3.3",
|
|
24
24
|
"webpack-cli": "5.1.4",
|
|
25
|
-
"webpack": "5.
|
|
25
|
+
"webpack": "5.89.0"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## About
|
|
2
2
|
|
|
3
|
-
This project has been created with _@adobe/create-ccweb-add-on_. As an example, this Add-on demonstrates how to get started with Add-on development using React and JavaScript with
|
|
3
|
+
This project has been created with _@adobe/create-ccweb-add-on_. As an example, this Add-on demonstrates how to get started with Add-on development using React and JavaScript with Document Sandbox Runtime.
|
|
4
4
|
|
|
5
5
|
## Tools
|
|
6
6
|
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
-
<meta
|
|
6
|
-
|
|
5
|
+
<meta
|
|
6
|
+
name="description"
|
|
7
|
+
content="Get started with Add-on development using React and JavaScript with Document Sandbox Runtime"
|
|
8
|
+
/>
|
|
9
|
+
<meta name="keywords" content="Adobe, Express, Add-On, React, JavaScript, Document Sandbox Runtime" />
|
|
7
10
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
|
-
<title>
|
|
11
|
+
<title>Get Started</title>
|
|
9
12
|
</head>
|
|
10
13
|
<body>
|
|
11
14
|
<div id="root"></div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"testId": "",
|
|
3
|
+
"name": "",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"manifestVersion": 2,
|
|
6
|
+
"requirements": {
|
|
7
|
+
"apps": [
|
|
8
|
+
{
|
|
9
|
+
"name": "Express",
|
|
10
|
+
"apiVersion": 1
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"experimentalApis": true
|
|
14
|
+
},
|
|
15
|
+
"entryPoints": [
|
|
16
|
+
{
|
|
17
|
+
"type": "panel",
|
|
18
|
+
"id": "panel1",
|
|
19
|
+
"main": "index.html",
|
|
20
|
+
"documentSandbox": "code.js"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { editor, utils } from "express";
|
|
1
|
+
import addOnSandboxSdk from "add-on-sdk-document-sandbox";
|
|
2
|
+
import { editor, utils } from "express-document-sdk";
|
|
3
3
|
|
|
4
|
-
// Get the
|
|
5
|
-
const { runtime } =
|
|
4
|
+
// Get the document sandbox runtime.
|
|
5
|
+
const { runtime } = addOnSandboxSdk.instance;
|
|
6
6
|
|
|
7
7
|
function start() {
|
|
8
8
|
// APIs to be exposed to the UI runtime
|
|
9
9
|
// i.e., to the `index.html` file of this add-on.
|
|
10
|
-
const
|
|
10
|
+
const sandboxApi = {
|
|
11
11
|
createRectangle: () => {
|
|
12
12
|
const rectangle = editor.createRectangle();
|
|
13
13
|
|
|
14
14
|
// Define rectangle dimensions.
|
|
15
|
-
rectangle.width =
|
|
16
|
-
rectangle.height =
|
|
15
|
+
rectangle.width = 240;
|
|
16
|
+
rectangle.height = 180;
|
|
17
17
|
|
|
18
18
|
// Define rectangle position.
|
|
19
|
-
rectangle.
|
|
20
|
-
rectangle.translateY = 100;
|
|
19
|
+
rectangle.translation = { x: 10, y: 10 };
|
|
21
20
|
|
|
22
21
|
// Define rectangle color.
|
|
23
22
|
const [red, green, blue, alpha] = [0.32, 0.34, 0.89, 1];
|
|
@@ -32,8 +31,8 @@ function start() {
|
|
|
32
31
|
}
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
// Expose
|
|
36
|
-
runtime.exposeApi(
|
|
34
|
+
// Expose `sandboxApi` to the UI runtime.
|
|
35
|
+
runtime.exposeApi(sandboxApi);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
start();
|
|
@@ -12,9 +12,9 @@ import { Theme } from "@swc-react/theme";
|
|
|
12
12
|
import React from "react";
|
|
13
13
|
import "./App.css";
|
|
14
14
|
|
|
15
|
-
const App = ({ addOnUISdk,
|
|
15
|
+
const App = ({ addOnUISdk, sandboxProxy }) => {
|
|
16
16
|
function handleClick() {
|
|
17
|
-
|
|
17
|
+
sandboxProxy.createRectangle();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
return (
|
|
@@ -11,10 +11,10 @@ addOnUISdk.ready.then(async () => {
|
|
|
11
11
|
const { runtime } = addOnUISdk.instance;
|
|
12
12
|
|
|
13
13
|
// Get the proxy object, which is required
|
|
14
|
-
// to call the APIs defined in the
|
|
14
|
+
// to call the APIs defined in the Document Sandbox runtime
|
|
15
15
|
// i.e., in the `code.js` file of this add-on.
|
|
16
|
-
const
|
|
16
|
+
const sandboxProxy = await runtime.apiProxy("documentSandbox");
|
|
17
17
|
|
|
18
18
|
const root = createRoot(document.getElementById("root"));
|
|
19
|
-
root.render(<App addOnUISdk={addOnUISdk}
|
|
19
|
+
root.render(<App addOnUISdk={addOnUISdk} sandboxProxy={sandboxProxy} />);
|
|
20
20
|
});
|
|
@@ -9,7 +9,7 @@ module.exports = {
|
|
|
9
9
|
devtool: "source-map",
|
|
10
10
|
entry: {
|
|
11
11
|
index: "./src/ui/index.jsx",
|
|
12
|
-
code: "./src/
|
|
12
|
+
code: "./src/sandbox/code.js"
|
|
13
13
|
},
|
|
14
14
|
experiments: {
|
|
15
15
|
outputModule: true
|
|
@@ -22,8 +22,8 @@ module.exports = {
|
|
|
22
22
|
externalsType: "module",
|
|
23
23
|
externalsPresets: { web: true },
|
|
24
24
|
externals: {
|
|
25
|
-
|
|
26
|
-
express: "express"
|
|
25
|
+
"add-on-sdk-document-sandbox": "add-on-sdk-document-sandbox",
|
|
26
|
+
"express-document-sdk": "express-document-sdk"
|
|
27
27
|
},
|
|
28
28
|
plugins: [
|
|
29
29
|
new HtmlWebpackPlugin({
|
|
@@ -6,22 +6,22 @@
|
|
|
6
6
|
"package": "ccweb-add-on-scripts package --use webpack"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@spectrum-web-components/theme": "0.
|
|
10
|
-
"@swc-react/button": "0.
|
|
11
|
-
"@swc-react/theme": "0.
|
|
9
|
+
"@spectrum-web-components/theme": "0.40.0",
|
|
10
|
+
"@swc-react/button": "0.40.0",
|
|
11
|
+
"@swc-react/theme": "0.40.0",
|
|
12
12
|
"react-dom": "18.2.0",
|
|
13
13
|
"react": "18.2.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@babel/core": "7.
|
|
17
|
-
"@babel/preset-env": "7.
|
|
18
|
-
"@babel/preset-react": "7.
|
|
16
|
+
"@babel/core": "7.23.3",
|
|
17
|
+
"@babel/preset-env": "7.23.3",
|
|
18
|
+
"@babel/preset-react": "7.23.3",
|
|
19
19
|
"babel-loader": "9.1.3",
|
|
20
20
|
"copy-webpack-plugin": "11.0.0",
|
|
21
21
|
"css-loader": "6.8.1",
|
|
22
22
|
"html-webpack-plugin": "5.5.3",
|
|
23
23
|
"style-loader": "3.3.3",
|
|
24
24
|
"webpack-cli": "5.1.4",
|
|
25
|
-
"webpack": "5.
|
|
25
|
+
"webpack": "5.89.0"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
"package": "ccweb-add-on-scripts package --use webpack"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@spectrum-web-components/theme": "0.
|
|
10
|
-
"@swc-react/button": "0.
|
|
11
|
-
"@swc-react/theme": "0.
|
|
9
|
+
"@spectrum-web-components/theme": "0.40.0",
|
|
10
|
+
"@swc-react/button": "0.40.0",
|
|
11
|
+
"@swc-react/theme": "0.40.0",
|
|
12
12
|
"react-dom": "18.2.0",
|
|
13
13
|
"react": "18.2.0"
|
|
14
14
|
},
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"css-loader": "6.8.1",
|
|
20
20
|
"html-webpack-plugin": "5.5.3",
|
|
21
21
|
"style-loader": "3.3.3",
|
|
22
|
-
"ts-loader": "9.
|
|
23
|
-
"typescript": "5.
|
|
22
|
+
"ts-loader": "9.5.1",
|
|
23
|
+
"typescript": "5.3.2",
|
|
24
24
|
"webpack-cli": "5.1.4",
|
|
25
|
-
"webpack": "5.
|
|
25
|
+
"webpack": "5.89.0"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## About
|
|
2
2
|
|
|
3
|
-
This project has been created with _@adobe/create-ccweb-add-on_. As an example, this Add-on demonstrates how to get started with Add-on development using React and TypeScript with
|
|
3
|
+
This project has been created with _@adobe/create-ccweb-add-on_. As an example, this Add-on demonstrates how to get started with Add-on development using React and TypeScript with Document Sandbox Runtime.
|
|
4
4
|
|
|
5
5
|
## Tools
|
|
6
6
|
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
-
<meta
|
|
6
|
-
|
|
5
|
+
<meta
|
|
6
|
+
name="description"
|
|
7
|
+
content="Get started with Add-on development using React and TypeScript with Document Sandbox Runtime"
|
|
8
|
+
/>
|
|
9
|
+
<meta name="keywords" content="Adobe, Express, Add-On, React, TypeScript, Document Sandbox Runtime" />
|
|
7
10
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
|
-
<title>
|
|
11
|
+
<title>Get Started</title>
|
|
9
12
|
</head>
|
|
10
13
|
<body>
|
|
11
14
|
<div id="root"></div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"testId": "",
|
|
3
|
+
"name": "",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"manifestVersion": 2,
|
|
6
|
+
"requirements": {
|
|
7
|
+
"apps": [
|
|
8
|
+
{
|
|
9
|
+
"name": "Express",
|
|
10
|
+
"apiVersion": 1
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"experimentalApis": true
|
|
14
|
+
},
|
|
15
|
+
"entryPoints": [
|
|
16
|
+
{
|
|
17
|
+
"type": "panel",
|
|
18
|
+
"id": "panel1",
|
|
19
|
+
"main": "index.html",
|
|
20
|
+
"documentSandbox": "code.js"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// DO NOT modify this file.
|
|
2
|
+
|
|
3
|
+
declare module "add-on-sdk-document-sandbox" {
|
|
4
|
+
import { AddOnDocumentSandboxSdkTypes } from "@adobe/ccweb-add-on-sdk-types";
|
|
5
|
+
export default AddOnDocumentSandboxSdkTypes.default;
|
|
6
|
+
export * from "@adobe/ccweb-add-on-sdk-types/sandbox/add-on-sdk-document-sandbox";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module "express-document-sdk" {
|
|
10
|
+
export * from "@adobe/ccweb-add-on-sdk-types/sandbox/express-document-sdk";
|
|
11
|
+
}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { editor, utils } from "express";
|
|
3
|
-
import {
|
|
1
|
+
import addOnSandboxSdk from "add-on-sdk-document-sandbox";
|
|
2
|
+
import { editor, utils } from "express-document-sdk";
|
|
3
|
+
import { DocumentSandboxApi } from "../models/DocumentSandboxApi";
|
|
4
4
|
|
|
5
|
-
// Get the
|
|
6
|
-
const { runtime } =
|
|
5
|
+
// Get the document sandbox runtime.
|
|
6
|
+
const { runtime } = addOnSandboxSdk.instance;
|
|
7
7
|
|
|
8
8
|
function start(): void {
|
|
9
9
|
// APIs to be exposed to the UI runtime
|
|
10
|
-
// i.e., to the `
|
|
11
|
-
const
|
|
10
|
+
// i.e., to the `App.tsx` file of this add-on.
|
|
11
|
+
const sandboxApi: DocumentSandboxApi = {
|
|
12
12
|
createRectangle: () => {
|
|
13
13
|
const rectangle = editor.createRectangle();
|
|
14
14
|
|
|
15
15
|
// Define rectangle dimensions.
|
|
16
|
-
rectangle.width =
|
|
17
|
-
rectangle.height =
|
|
16
|
+
rectangle.width = 240;
|
|
17
|
+
rectangle.height = 180;
|
|
18
18
|
|
|
19
19
|
// Define rectangle position.
|
|
20
|
-
rectangle.
|
|
21
|
-
rectangle.translateY = 100;
|
|
20
|
+
rectangle.translation = { x: 10, y: 10 };
|
|
22
21
|
|
|
23
22
|
// Define rectangle color.
|
|
24
23
|
const [red, green, blue, alpha] = [0.32, 0.34, 0.89, 1];
|
|
@@ -33,8 +32,8 @@ function start(): void {
|
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
34
|
|
|
36
|
-
// Expose `
|
|
37
|
-
runtime.exposeApi(
|
|
35
|
+
// Expose `sandboxApi` to the UI runtime.
|
|
36
|
+
runtime.exposeApi(sandboxApi);
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
start();
|
|
@@ -10,14 +10,14 @@ import "@spectrum-web-components/theme/theme-light.js";
|
|
|
10
10
|
import { Button } from "@swc-react/button";
|
|
11
11
|
import { Theme } from "@swc-react/theme";
|
|
12
12
|
import React from "react";
|
|
13
|
-
import {
|
|
13
|
+
import { DocumentSandboxApi } from "../../models/DocumentSandboxApi";
|
|
14
14
|
import "./App.css";
|
|
15
15
|
|
|
16
16
|
import { AddOnSDKAPI } from "https://new.express.adobe.com/static/add-on-sdk/sdk.js";
|
|
17
17
|
|
|
18
|
-
const App = ({ addOnUISdk,
|
|
18
|
+
const App = ({ addOnUISdk, sandboxProxy }: { addOnUISdk: AddOnSDKAPI; sandboxProxy: DocumentSandboxApi }) => {
|
|
19
19
|
function handleClick() {
|
|
20
|
-
|
|
20
|
+
sandboxProxy.createRectangle();
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { createRoot } from "react-dom/client";
|
|
3
|
-
import {
|
|
3
|
+
import { DocumentSandboxApi } from "../models/DocumentSandboxApi";
|
|
4
4
|
import App from "./components/App";
|
|
5
5
|
|
|
6
6
|
import addOnUISdk, { RuntimeType } from "https://new.express.adobe.com/static/add-on-sdk/sdk.js";
|
|
@@ -12,10 +12,10 @@ addOnUISdk.ready.then(async () => {
|
|
|
12
12
|
const { runtime } = addOnUISdk.instance;
|
|
13
13
|
|
|
14
14
|
// Get the proxy object, which is required
|
|
15
|
-
// to call the APIs defined in the
|
|
16
|
-
// i.e., in the `code.
|
|
17
|
-
const
|
|
15
|
+
// to call the APIs defined in the Document Sandbox runtime
|
|
16
|
+
// i.e., in the `code.ts` file of this add-on.
|
|
17
|
+
const sandboxProxy: DocumentSandboxApi = await runtime.apiProxy(RuntimeType.documentSandbox);
|
|
18
18
|
|
|
19
19
|
const root = createRoot(document.getElementById("root"));
|
|
20
|
-
root.render(<App addOnUISdk={addOnUISdk}
|
|
20
|
+
root.render(<App addOnUISdk={addOnUISdk} sandboxProxy={sandboxProxy} />);
|
|
21
21
|
});
|