@canva/design 0.0.1-rc.1

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.
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./public"), exports);
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initAppElement = exports.getCurrentPageContext = exports.addAudioTrack = exports.addNativeElement = exports.ui = exports.requestExport = exports.getDefaultPageDimensions = exports.addPage = void 0;
4
+ const { canva } = window;
5
+ /**
6
+ * @public
7
+ * Adds a new page immediately after the currently selected page.
8
+ * @param opts - Configuration for the new page to be added.
9
+ */
10
+ function addPage(opts) {
11
+ return canva.designInteraction.addPage(opts);
12
+ }
13
+ exports.addPage = addPage;
14
+ /**
15
+ * @public
16
+ * Gets the default dimensions that a new page will have when it is added to a design.
17
+ * It is possible for a user to resize a page without resizing the entire design, e.g. by clicking
18
+ * "Expand to Whiteboard". However, there will always be a single set of default dimensions for a
19
+ * design that is applied whenever a new page is created.
20
+ *
21
+ * Returns `undefined` if the design is unbounded (e.g. Whiteboard or Doc).
22
+ */
23
+ function getDefaultPageDimensions() {
24
+ return canva.designInteraction.getDefaultPageDimensions();
25
+ }
26
+ exports.getDefaultPageDimensions = getDefaultPageDimensions;
27
+ /**
28
+ * @public
29
+ * Exports the user's design as one or more static files.
30
+ * @param request - The request object containing configurations of the design export.
31
+ */
32
+ function requestExport(request) {
33
+ return canva.export.requestExport(request);
34
+ }
35
+ exports.requestExport = requestExport;
36
+ /**
37
+ * An alias for the UI interface, providing access to ui related functionality
38
+ * @public
39
+ */
40
+ exports.ui = canva.dragAndDrop;
41
+ /**
42
+ * @public
43
+ * Adds a native element to the user's design.
44
+ * @param element - The element to add to the user's design.
45
+ */
46
+ function addNativeElement(element) {
47
+ return canva.designInteraction.addNativeElement(element);
48
+ }
49
+ exports.addNativeElement = addNativeElement;
50
+ /**
51
+ * Adds an audio track to the user's design.
52
+ * @public
53
+ * @param audioTrack - The audio track to add to the user's design.
54
+ */
55
+ function addAudioTrack(audioTrack) {
56
+ return canva.designInteraction.addAudioTrack(audioTrack);
57
+ }
58
+ exports.addAudioTrack = addAudioTrack;
59
+ /**
60
+ * Allows to get the context of currently selected page.
61
+ * @public
62
+ * @returns Page context of currently selected page
63
+ */
64
+ function getCurrentPageContext() {
65
+ return canva.designInteraction.getCurrentPageContext();
66
+ }
67
+ exports.getCurrentPageContext = getCurrentPageContext;
68
+ /**
69
+ * @public
70
+ * @param appElementConfig - Configuration for an AppElementClient
71
+ */
72
+ function initAppElement(appElementConfig) {
73
+ return canva.designInteraction.initAppElement(appElementConfig);
74
+ }
75
+ exports.initAppElement = initAppElement;
@@ -0,0 +1 @@
1
+ export * from './public';
@@ -0,0 +1,65 @@
1
+ const { canva } = window;
2
+ /**
3
+ * @public
4
+ * Adds a new page immediately after the currently selected page.
5
+ * @param opts - Configuration for the new page to be added.
6
+ */
7
+ export function addPage(opts) {
8
+ return canva.designInteraction.addPage(opts);
9
+ }
10
+ /**
11
+ * @public
12
+ * Gets the default dimensions that a new page will have when it is added to a design.
13
+ * It is possible for a user to resize a page without resizing the entire design, e.g. by clicking
14
+ * "Expand to Whiteboard". However, there will always be a single set of default dimensions for a
15
+ * design that is applied whenever a new page is created.
16
+ *
17
+ * Returns `undefined` if the design is unbounded (e.g. Whiteboard or Doc).
18
+ */
19
+ export function getDefaultPageDimensions() {
20
+ return canva.designInteraction.getDefaultPageDimensions();
21
+ }
22
+ /**
23
+ * @public
24
+ * Exports the user's design as one or more static files.
25
+ * @param request - The request object containing configurations of the design export.
26
+ */
27
+ export function requestExport(request) {
28
+ return canva.export.requestExport(request);
29
+ }
30
+ /**
31
+ * An alias for the UI interface, providing access to ui related functionality
32
+ * @public
33
+ */
34
+ export const ui = canva.dragAndDrop;
35
+ /**
36
+ * @public
37
+ * Adds a native element to the user's design.
38
+ * @param element - The element to add to the user's design.
39
+ */
40
+ export function addNativeElement(element) {
41
+ return canva.designInteraction.addNativeElement(element);
42
+ }
43
+ /**
44
+ * Adds an audio track to the user's design.
45
+ * @public
46
+ * @param audioTrack - The audio track to add to the user's design.
47
+ */
48
+ export function addAudioTrack(audioTrack) {
49
+ return canva.designInteraction.addAudioTrack(audioTrack);
50
+ }
51
+ /**
52
+ * Allows to get the context of currently selected page.
53
+ * @public
54
+ * @returns Page context of currently selected page
55
+ */
56
+ export function getCurrentPageContext() {
57
+ return canva.designInteraction.getCurrentPageContext();
58
+ }
59
+ /**
60
+ * @public
61
+ * @param appElementConfig - Configuration for an AppElementClient
62
+ */
63
+ export function initAppElement(appElementConfig) {
64
+ return canva.designInteraction.initAppElement(appElementConfig);
65
+ }
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@canva/design",
3
+ "version": "0.0.1-rc.1",
4
+ "description": "The Canva Apps SDK design library",
5
+ "author": "Canva Pty Ltd.",
6
+ "license": "SEE LICENSE IN LICENSE.md FILE",
7
+ "peerDependencies": {
8
+ "@canva/error": "^0.0.1-rc.1"
9
+ },
10
+ "main": "lib/cjs/sdk/design/index.js",
11
+ "module": "lib/esm/sdk/design/index.js",
12
+ "exports": {
13
+ ".": {
14
+ "require": "./lib/cjs/sdk/design/index.js",
15
+ "import": "./lib/esm/sdk/design/index.js"
16
+ }
17
+ },
18
+ "typings": "./index.d.ts"
19
+ }