@canva/design 2.3.0 → 2.4.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/index.d.ts CHANGED
@@ -87,6 +87,10 @@ export declare type AppElementChangeHandler<A extends AppElementData> = (
87
87
  * The version number of the app.
88
88
  */
89
89
  version: number;
90
+ /**
91
+ * Function to update the app element data.
92
+ */
93
+ update: (opts: AppElementOptions<A>) => Promise<void>;
90
94
  }
91
95
  | undefined,
92
96
  ) => void;
@@ -97,13 +101,18 @@ export declare type AppElementChangeHandler<A extends AppElementData> = (
97
101
  */
98
102
  export declare interface AppElementClient<A extends AppElementData> {
99
103
  /**
104
+ * @deprecated This type has been superseded, use `addElement` or `registerOnElementChange` instead.
100
105
  * If an app element is selected, the element's data is overwritten and the element is re-rendered.
101
106
  * Otherwise, the provided data is used to create a new app element.
102
107
  * @param appElementData - The data to attach to the app element. Existing data will be overwritten.
103
108
  * @param placement - The position, dimensions, and rotation of the app element.
104
109
  */
105
110
  addOrUpdateElement(appElementData: A, placement?: Placement): Promise<void>;
106
-
111
+ /**
112
+ * Adds a new app element to the design.
113
+ * @param opts - The data and placement of the app element.
114
+ */
115
+ addElement(opts: AppElementOptions<A>): Promise<void>;
107
116
  /**
108
117
  * A callback that runs when:
109
118
  *
@@ -133,6 +142,22 @@ export declare type AppElementClientConfiguration<A extends AppElementData> = {
133
142
  */
134
143
  export declare type AppElementData = Record<string, Value>;
135
144
 
145
+ /**
146
+ * @public
147
+ * Used to add or update an app element to the design.
148
+ * The update function is provided in the AppElementChangeHandler callback (registerOnElementChange).
149
+ */
150
+ export declare type AppElementOptions<A extends AppElementData> = {
151
+ /**
152
+ * The data to attach to the app element.
153
+ */
154
+ data: A;
155
+ /**
156
+ * The position, dimensions, and rotation of the app element.
157
+ */
158
+ placement?: Placement;
159
+ };
160
+
136
161
  /**
137
162
  * @public
138
163
  * A callback function that renders an app element based on the data it receives.
@@ -720,7 +745,7 @@ export declare type Fill = {
720
745
  * The hex code must include all six characters and be prefixed with a `#` symbol.
721
746
  *
722
747
  * @example
723
- * " #ff0099"
748
+ * "#ff0099"
724
749
  */
725
750
  color?: string;
726
751
  /**
@@ -17,4 +17,4 @@ function _export_star(from, to) {
17
17
  return from;
18
18
  }
19
19
  var _window___canva___sdkRegistration, _window___canva__;
20
- (_window___canva__ = 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.3.0', 'ga');
20
+ (_window___canva__ = 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.4.0', 'ga');
@@ -9,53 +9,53 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- selection: function() {
13
- return selection;
14
- },
15
- overlay: function() {
16
- return overlay;
17
- },
18
- addPage: function() {
19
- return addPage;
20
- },
21
- setCurrentPageBackground: function() {
22
- return setCurrentPageBackground;
23
- },
24
- getDefaultPageDimensions: function() {
25
- return getDefaultPageDimensions;
12
+ addAudioTrack: function() {
13
+ return addAudioTrack;
26
14
  },
27
- requestExport: function() {
28
- return requestExport;
15
+ addElementAtCursor: function() {
16
+ return addElementAtCursor;
29
17
  },
30
- ui: function() {
31
- return ui;
18
+ addElementAtPoint: function() {
19
+ return addElementAtPoint;
32
20
  },
33
21
  addNativeElement: function() {
34
22
  return addNativeElement;
35
23
  },
36
- addElementAtPoint: function() {
37
- return addElementAtPoint;
24
+ addPage: function() {
25
+ return addPage;
38
26
  },
39
- addElementAtCursor: function() {
40
- return addElementAtCursor;
27
+ createRichtextRange: function() {
28
+ return createRichtextRange;
41
29
  },
42
- addAudioTrack: function() {
43
- return addAudioTrack;
30
+ editContent: function() {
31
+ return editContent;
44
32
  },
45
33
  getCurrentPageContext: function() {
46
34
  return getCurrentPageContext;
47
35
  },
48
- initAppElement: function() {
49
- return initAppElement;
36
+ getDefaultPageDimensions: function() {
37
+ return getDefaultPageDimensions;
50
38
  },
51
39
  getDesignToken: function() {
52
40
  return getDesignToken;
53
41
  },
54
- createRichtextRange: function() {
55
- return createRichtextRange;
42
+ initAppElement: function() {
43
+ return initAppElement;
56
44
  },
57
- editContent: function() {
58
- return editContent;
45
+ overlay: function() {
46
+ return overlay;
47
+ },
48
+ requestExport: function() {
49
+ return requestExport;
50
+ },
51
+ selection: function() {
52
+ return selection;
53
+ },
54
+ setCurrentPageBackground: function() {
55
+ return setCurrentPageBackground;
56
+ },
57
+ ui: function() {
58
+ return ui;
59
59
  }
60
60
  });
61
61
  const { canva_sdk } = window;
@@ -9,12 +9,12 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- getCanvaSdk: function() {
13
- return getCanvaSdk;
14
- },
15
12
  assertIsTestCanvaSdk: function() {
16
13
  return assertIsTestCanvaSdk;
17
14
  },
15
+ getCanvaSdk: function() {
16
+ return getCanvaSdk;
17
+ },
18
18
  injectFakeAPIClients: function() {
19
19
  return injectFakeAPIClients;
20
20
  }
@@ -1,3 +1,3 @@
1
1
  var _window___canva___sdkRegistration, _window___canva__;
2
2
  export * from './public';
3
- (_window___canva__ = 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.3.0', 'ga');
3
+ (_window___canva__ = 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.4.0', 'ga');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canva/design",
3
- "version": "2.3.0",
3
+ "version": "2.4.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",