@canva/design 1.11.0-beta.1 → 2.0.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.
@@ -0,0 +1,21 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./public"), exports);
6
+ function _export_star(from, to) {
7
+ Object.keys(from).forEach(function(k) {
8
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
+ Object.defineProperty(to, k, {
10
+ enumerable: true,
11
+ get: function() {
12
+ return from[k];
13
+ }
14
+ });
15
+ }
16
+ });
17
+ return from;
18
+ }
19
+ var _window___canva___sdkRegistration, _window___canva__;
20
+ (_window___canva__ =
21
+ window.__canva__) === null || _window___canva__ === void 0 ? void 0 : (_window___canva___sdkRegistration = _window___canva__.sdkRegistration) === null || _window___canva___sdkRegistration === void 0 ? void 0 : _window___canva___sdkRegistration.registerPackageVersion('design', '2.0.0', 'ga');
@@ -1,5 +1,4 @@
1
- // Copyright 2023 Canva Inc. All Rights Reserved.
2
- "use strict";
1
+ "use strict"
3
2
  Object.defineProperty(exports, "__esModule", {
4
3
  value: true
5
4
  });
@@ -34,6 +33,12 @@ _export(exports, {
34
33
  addNativeElement: function() {
35
34
  return addNativeElement;
36
35
  },
36
+ addElementAtPoint: function() {
37
+ return addElementAtPoint;
38
+ },
39
+ addElementAtCursor: function() {
40
+ return addElementAtCursor;
41
+ },
37
42
  addAudioTrack: function() {
38
43
  return addAudioTrack;
39
44
  },
@@ -45,36 +50,30 @@ _export(exports, {
45
50
  },
46
51
  getDesignToken: function() {
47
52
  return getDesignToken;
53
+ },
54
+ createRichtextRange: function() {
55
+ return createRichtextRange;
48
56
  }
49
57
  });
50
- const { canva } = window;
51
- const selection = canva.designInteraction.selection;
52
- const overlay = canva.designInteraction.overlay;
53
- function addPage(opts) {
54
- return canva.designInteraction.addPage(opts);
55
- }
56
- function setCurrentPageBackground(opts) {
57
- return canva.designInteraction.setCurrentPageBackground(opts);
58
- }
59
- function getDefaultPageDimensions() {
60
- return canva.designInteraction.getDefaultPageDimensions();
61
- }
62
- function requestExport(request) {
63
- return canva.export.requestExport(request);
64
- }
65
- const ui = canva.dragAndDrop;
66
- function addNativeElement(element) {
67
- return canva.designInteraction.addNativeElement(element);
68
- }
69
- function addAudioTrack(audioTrack) {
70
- return canva.designInteraction.addAudioTrack(audioTrack);
71
- }
72
- function getCurrentPageContext() {
73
- return canva.designInteraction.getCurrentPageContext();
74
- }
58
+ const { canva_sdk } = window;
59
+ const selection = canva_sdk.design.v2.designInteraction.selection;
60
+ const overlay = canva_sdk.design.v2.designInteraction.overlay;
61
+ const addPage = canva_sdk.design.v2.designInteraction.addPage;
62
+ const setCurrentPageBackground = canva_sdk.design.v2.designInteraction.setCurrentPageBackground;
63
+ const getDefaultPageDimensions = canva_sdk.design.v2.designInteraction.getDefaultPageDimensions;
64
+ const requestExport = canva_sdk.design.v2.export.requestExport;
65
+ const ui = canva_sdk.design.v2.dragAndDrop;
66
+ const addNativeElement = canva_sdk.design.v2.designInteraction.addNativeElement;
67
+ const addElementAtPoint = canva_sdk.design.v2.designInteraction.addElementAtPoint;
68
+ const addElementAtCursor = canva_sdk.design.v2.designInteraction.addElementAtCursor;
69
+ const addAudioTrack = canva_sdk.design.v2.designInteraction.addAudioTrack;
70
+ const getCurrentPageContext = canva_sdk.design.v2.designInteraction.getCurrentPageContext;
75
71
  function initAppElement(appElementConfig) {
76
- return canva.designInteraction.initAppElement(appElementConfig);
72
+ return canva_sdk.design.v2.designInteraction.initAppElement(appElementConfig);
77
73
  }
78
74
  function getDesignToken() {
79
- return canva.designInteraction.getDesignToken();
75
+ return canva_sdk.design.v2.designInteraction.getDesignToken();
76
+ }
77
+ function createRichtextRange() {
78
+ return canva_sdk.design.v2.designInteraction.createRichtextRange();
80
79
  }
@@ -0,0 +1,4 @@
1
+ var _window___canva___sdkRegistration, _window___canva__;
2
+ export * from './public';
3
+ (_window___canva__ =
4
+ window.__canva__) === null || _window___canva__ === void 0 ? void 0 : (_window___canva___sdkRegistration = _window___canva__.sdkRegistration) === null || _window___canva___sdkRegistration === void 0 ? void 0 : _window___canva___sdkRegistration.registerPackageVersion('design', '2.0.0', 'ga');
@@ -1,79 +1,22 @@
1
- // Copyright 2023 Canva Inc. All Rights Reserved.
2
- const { canva } = window;
3
- /**
4
- * @public
5
- * An alias for the DesignSelection interface, providing access to design selection related functionality
6
- */ export const selection = canva.designInteraction.selection;
7
- /**
8
- * @public
9
- * An alias for the DesignOverlay interface, providing access to design overlay related functionality
10
- */ export const overlay = canva.designInteraction.overlay;
11
- /**
12
- * @public
13
- * Adds a new page immediately after the currently selected page.
14
- * @param opts - Configuration for the new page to be added.
15
- */ export function addPage(opts) {
16
- return canva.designInteraction.addPage(opts);
17
- }
18
- /**
19
- * @public
20
- * Updates the background of the user's current page. The background can be a solid color,
21
- * an image or a video.
22
- */ export function setCurrentPageBackground(opts) {
23
- return canva.designInteraction.setCurrentPageBackground(opts);
24
- }
25
- /**
26
- * @public
27
- * Gets the default dimensions that a new page will have when it is added to a design.
28
- * It is possible for a user to resize a page without resizing the entire design, e.g. by clicking
29
- * "Expand to Whiteboard". However, there will always be a single set of default dimensions for a
30
- * design that is applied whenever a new page is created.
31
- *
32
- * Returns `undefined` if the design is unbounded (e.g. Whiteboard or Doc).
33
- */ export function getDefaultPageDimensions() {
34
- return canva.designInteraction.getDefaultPageDimensions();
35
- }
36
- /**
37
- * @public
38
- * Exports the user's design as one or more static files.
39
- * @param request - The request object containing configurations of the design export.
40
- */ export function requestExport(request) {
41
- return canva.export.requestExport(request);
42
- }
43
- /**
44
- * An alias for the UI interface, providing access to ui related functionality
45
- * @public
46
- */ export const ui = canva.dragAndDrop;
47
- /**
48
- * @public
49
- * Adds a native element to the user's design.
50
- * @param element - The element to add to the user's design.
51
- */ export function addNativeElement(element) {
52
- return canva.designInteraction.addNativeElement(element);
53
- }
54
- /**
55
- * Adds an audio track to the user's design.
56
- * @public
57
- * @param audioTrack - The audio track to add to the user's design.
58
- */ export function addAudioTrack(audioTrack) {
59
- return canva.designInteraction.addAudioTrack(audioTrack);
60
- }
61
- /**
62
- * Allows to get the context of currently selected page.
63
- * @public
64
- * @returns Page context of currently selected page
65
- */ export function getCurrentPageContext() {
66
- return canva.designInteraction.getCurrentPageContext();
67
- }
68
- /**
69
- * @public
70
- * @param appElementConfig - Configuration for an AppElementClient
71
- */ export function initAppElement(appElementConfig) {
72
- return canva.designInteraction.initAppElement(appElementConfig);
73
- }
74
- /**
75
- * @public
76
- * Retrieves a signed JWT that contains the Design ID, App ID and User ID.
77
- */ export function getDesignToken() {
78
- return canva.designInteraction.getDesignToken();
1
+ const { canva_sdk } = window;
2
+ export const selection = canva_sdk.design.v2.designInteraction.selection;
3
+ export const overlay = canva_sdk.design.v2.designInteraction.overlay;
4
+ export const addPage = canva_sdk.design.v2.designInteraction.addPage;
5
+ export const setCurrentPageBackground = canva_sdk.design.v2.designInteraction.setCurrentPageBackground;
6
+ export const getDefaultPageDimensions = canva_sdk.design.v2.designInteraction.getDefaultPageDimensions;
7
+ export const requestExport = canva_sdk.design.v2.export.requestExport;
8
+ export const ui = canva_sdk.design.v2.dragAndDrop;
9
+ export const addNativeElement = canva_sdk.design.v2.designInteraction.addNativeElement;
10
+ export const addElementAtPoint = canva_sdk.design.v2.designInteraction.addElementAtPoint;
11
+ export const addElementAtCursor = canva_sdk.design.v2.designInteraction.addElementAtCursor;
12
+ export const addAudioTrack = canva_sdk.design.v2.designInteraction.addAudioTrack;
13
+ export const getCurrentPageContext = canva_sdk.design.v2.designInteraction.getCurrentPageContext;
14
+ export function initAppElement(appElementConfig) {
15
+ return canva_sdk.design.v2.designInteraction.initAppElement(appElementConfig);
16
+ }
17
+ export function getDesignToken() {
18
+ return canva_sdk.design.v2.designInteraction.getDesignToken();
19
+ }
20
+ export function createRichtextRange() {
21
+ return canva_sdk.design.v2.designInteraction.createRichtextRange();
79
22
  }
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@canva/design",
3
- "version": "1.11.0-beta.1",
3
+ "version": "2.0.0",
4
4
  "description": "The Canva Apps SDK design library",
5
5
  "author": "Canva Pty Ltd.",
6
6
  "license": "SEE LICENSE IN LICENSE.md FILE",
7
7
  "peerDependencies": {
8
- "@canva/error": "^1.0.0"
8
+ "@canva/error": "^2.0.0"
9
9
  },
10
- "main": "./lib/cjs/sdk/design/beta.js",
11
- "module": "./lib/esm/sdk/design/beta.js",
10
+ "main": "./lib/cjs/sdk/design/index.js",
11
+ "module": "./lib/esm/sdk/design/index.js",
12
12
  "exports": {
13
13
  ".": {
14
14
  "require": {
15
- "types": "./beta.d.ts",
16
- "default": "./lib/cjs/sdk/design/beta.js"
15
+ "types": "./index.d.ts",
16
+ "default": "./lib/cjs/sdk/design/index.js"
17
17
  },
18
18
  "import": {
19
- "types": "./beta.d.ts",
20
- "default": "./lib/esm/sdk/design/beta.js"
19
+ "types": "./index.d.ts",
20
+ "default": "./lib/esm/sdk/design/index.js"
21
21
  }
22
22
  }
23
23
  },
24
- "typings": "./beta.d.ts"
25
- }
24
+ "typings": "./index.d.ts"
25
+ }