@canva/design 1.10.0-beta.1 → 1.10.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.
@@ -5,20 +5,6 @@
5
5
  */
6
6
  export declare function addAudioTrack(audioTrack: AudioTrack): Promise<void>;
7
7
 
8
- /**
9
- * @beta
10
- * Adds a native element to the user's design.
11
- * @param element - The element to add to the user's design.
12
- */
13
- export declare function addNativeElement(
14
- element:
15
- | NativeElement
16
- | NativeElementWithBox
17
- | NativeTableElement
18
- | NativeRichtextElement
19
- | NativeRichtextElementWithBox
20
- ): Promise<void>;
21
-
22
8
  /**
23
9
  * @public
24
10
  * Adds a native element to the user's design.
@@ -182,24 +168,6 @@ export declare type AudioTrack = {
182
168
  ref: AudioRef;
183
169
  };
184
170
 
185
- /**
186
- * @beta
187
- * The boundaries of a rich text region.
188
- */
189
- export declare type Bounds = {
190
- /**
191
- * The index of the character from which the region starts.
192
- *
193
- * @remarks
194
- * A value of `0` means the region starts from the first character.
195
- */
196
- index: number;
197
- /**
198
- * The length of the text region.
199
- */
200
- length: number;
201
- };
202
-
203
171
  /**
204
172
  * @public
205
173
  * The dimensions, position, and rotation of an element.
@@ -209,31 +177,6 @@ export declare type Bounds = {
209
177
  */
210
178
  export declare type Box = Position & (WidthAndHeight | Width | Height);
211
179
 
212
- /**
213
- * @beta
214
- * A cell for a NativeTableElement. Cells can have text content and a background color.
215
- * A cell can also be sized by setting the colSpan and rowSpan values for how many columns
216
- * and rows the cell occupies respectively.
217
- */
218
- export declare type Cell = {
219
- /**
220
- * The text content of the table cell
221
- */
222
- text?: NativeTextElement;
223
- /**
224
- * The background of the table cell
225
- */
226
- fill?: Pick<Fill, "color">;
227
- /**
228
- * How many columns this cell occupies
229
- */
230
- colSpan?: number;
231
- /**
232
- * How many rows this cell occupies
233
- */
234
- rowSpan?: number;
235
- };
236
-
237
180
  declare type CommonImageDragConfig = {
238
181
  /**
239
182
  * The type of element.
@@ -272,20 +215,6 @@ export declare interface ContentDraft<T> {
272
215
  save(): Promise<void>;
273
216
  }
274
217
 
275
- /**
276
- * @beta
277
- * A type of content that can be read from a user's design.
278
- */
279
- export declare type ContentType = "richtext";
280
-
281
- /**
282
- * @beta
283
- * Options for configuring where content in a design should be queried from.
284
- */
285
- declare type ContextOptions = {
286
- context: "current_page";
287
- };
288
-
289
218
  /**
290
219
  * @public
291
220
  * Represents X and Y coordinates.
@@ -301,12 +230,6 @@ export declare type Coordinates = {
301
230
  y: number;
302
231
  };
303
232
 
304
- /**
305
- * @beta
306
- * Creates a new RichtextRange object, which contains methods to manipulate text.
307
- */
308
- export declare function createRichtextRange(): RichtextRange;
309
-
310
233
  /**
311
234
  * @public
312
235
  * Provides methods for interacting with design overlay
@@ -325,7 +248,7 @@ export declare type DesignOverlay = {
325
248
  };
326
249
 
327
250
  /**
328
- * @beta
251
+ * @public
329
252
  * Provides methods for interacting with the user's selected content, such as images or text.
330
253
  */
331
254
  export declare type DesignSelection = {
@@ -406,14 +329,6 @@ export declare type DragStartEvent<E extends Element> = Pick<
406
329
  currentTarget: E;
407
330
  };
408
331
 
409
- /**
410
- * @beta
411
- * Options for configuring how a design is read.
412
- */
413
- export declare type EditContentOptions<T extends ContentType> = {
414
- contentType: T;
415
- } & ContextOptions;
416
-
417
332
  /**
418
333
  * @public
419
334
  * Options for making an `HTMLElement` draggable.
@@ -748,50 +663,6 @@ export declare function initAppElement<A extends AppElementData>(
748
663
  appElementConfig: AppElementClientConfiguration<A>
749
664
  ): AppElementClient<A>;
750
665
 
751
- /**
752
- * @beta
753
- *
754
- * Inline formatting values for richtext
755
- */
756
- export declare type InlineFormatting = {
757
- /**
758
- * The color of the text as a hex code.
759
- *
760
- * @remarks
761
- * The hex code must include all six characters and be prefixed with a # symbol
762
- * (e.g. #ff0099). The default value is #000000.
763
- */
764
- color?: string;
765
- /**
766
- * The weight (thickness) of the font.
767
- *
768
- * @remarks
769
- * The available font weights depend on the font.
770
- *
771
- * @defaultValue 'normal'
772
- */
773
- fontWeight?: FontWeight;
774
- /**
775
- * The style of the font.
776
- * @defaultValue 'normal'
777
- */
778
- fontStyle?: "normal" | "italic";
779
- /**
780
- * The decoration of the text.
781
- * @defaultValue 'none'
782
- */
783
- decoration?: "none" | "underline";
784
- /**
785
- * The strikethrough of the text.
786
- * @defaultValue 'none'
787
- */
788
- strikethrough?: "none" | "strikethrough";
789
- /**
790
- * A url that the underlying text will link to
791
- */
792
- link?: string;
793
- };
794
-
795
666
  /**
796
667
  * @public
797
668
  * A native element.
@@ -950,34 +821,6 @@ export declare type NativeImageElement = {
950
821
  */
951
822
  export declare type NativeImageElementWithBox = NativeImageElement & Box;
952
823
 
953
- /**
954
- * @beta
955
- * An element that renders richtext.
956
- */
957
- export declare type NativeRichtextElement = {
958
- /**
959
- * The type of element.
960
- */
961
- type: "RICHTEXT";
962
- /**
963
- * An object containing rich text which exposes methods to manipulate the text.
964
- */
965
- range: RichtextRange;
966
- };
967
-
968
- /**
969
- * @beta
970
- * An element that renders richtext.
971
- *
972
- * @remarks
973
- * This type includes properties for controlling the position and dimensions of the
974
- * element.
975
- * It will be positioned and sized relative to its parent container.
976
- * The parent container may be an app element, or the current page.
977
- */
978
- export declare type NativeRichtextElementWithBox = NativeRichtextElement &
979
- TextBox;
980
-
981
824
  /**
982
825
  * @public
983
826
  * An element that renders a vector shape.
@@ -1041,23 +884,6 @@ export declare type NativeSimpleElementWithBox = Exclude<
1041
884
  NativeGroupElementWithBox
1042
885
  >;
1043
886
 
1044
- /**
1045
- * @beta
1046
- * An element that renders a table.
1047
- */
1048
- export declare type NativeTableElement = {
1049
- /**
1050
- * The type of element.
1051
- */
1052
- type: "TABLE";
1053
- /**
1054
- * The rows of the table. Each row contains an array of cells, 1 cell per column in the row.
1055
- */
1056
- rows: {
1057
- cells: Cell[];
1058
- }[];
1059
- };
1060
-
1061
887
  /**
1062
888
  * @public
1063
889
  * An element that renders text.
@@ -1298,50 +1124,6 @@ declare type Position = {
1298
1124
  */
1299
1125
  declare type Primitive = undefined | null | number | boolean | string;
1300
1126
 
1301
- /**
1302
- * @beta
1303
- * A snapshot of content returned by a query.
1304
- *
1305
- * @remarks
1306
- * The snapshot is known as the *draft*.
1307
- */
1308
- export declare interface QueryContentDraft<T> {
1309
- /**
1310
- * The individual content items returned by a query.
1311
- */
1312
- readonly contents: readonly T[];
1313
- /**
1314
- * Commits any changes made to the items in the `contents` array.
1315
- *
1316
- * @remarks
1317
- * An app must call this method for any changes to be reflected in the user's design.
1318
- */
1319
- sync(): Promise<void>;
1320
- }
1321
-
1322
- /**
1323
- * @beta
1324
- * The result of querying content in a design.
1325
- */
1326
- export declare type QueryResult<T extends ContentType> = {
1327
- ["richtext"]: QueryContentDraft<
1328
- RichtextRange & {
1329
- readonly deleted: boolean;
1330
- }
1331
- >;
1332
- }[T];
1333
-
1334
- /**
1335
- * @beta
1336
- * Reads content of the specified type from the user's design.
1337
- * @param options - Options for configuring how a design is read.
1338
- * @param callback - A callback for operating on the queried content.
1339
- */
1340
- export declare function readContent<T extends ContentType>(
1341
- options: EditContentOptions<T>,
1342
- callback: (draft: QueryResult<T>) => Promise<void> | void
1343
- ): Promise<void>;
1344
-
1345
1127
  /**
1346
1128
  * @public
1347
1129
  * Exports the user's design as one or more static files.
@@ -1352,127 +1134,13 @@ export declare function requestExport(
1352
1134
  ): Promise<ExportResponse>;
1353
1135
 
1354
1136
  /**
1355
- * @beta
1356
- *
1357
- * Formatting values for richtext
1358
- */
1359
- export declare type RichtextFormatting = InlineFormatting & {
1360
- /**
1361
- * @public
1362
- * A reference to the font to use for this text element.
1363
- */
1364
- fontRef?: FontRef;
1365
- /**
1366
- * The size of the text, in pixels.
1367
- *
1368
- * @remarks
1369
- * This must be an integer between 1 and 1000.
1370
- * In the UI of the Canva editor, this number is shown as points (pts), not pixels.
1371
- */
1372
- fontSize?: number;
1373
- /**
1374
- * The alignment of the text.
1375
- * @defaultValue 'start'
1376
- */
1377
- textAlign?: "start" | "center" | "end" | "justify";
1378
- /**
1379
- * The list indentation level of the current paragraph.
1380
- */
1381
- listLevel?: number;
1382
- /**
1383
- * The appearance of the marker for list items.
1384
- *
1385
- * @remarks
1386
- * This property only has an effect if `listLevel` is a number greater than 0.
1387
- *
1388
- * @defaultValue 'none'
1389
- */
1390
- listMarker?:
1391
- | "none"
1392
- | "disc"
1393
- | "circle"
1394
- | "square"
1395
- | "decimal"
1396
- | "lower-alpha"
1397
- | "lower-roman"
1398
- | "checked"
1399
- | "unchecked";
1400
- };
1401
-
1402
- /**
1403
- * @beta
1404
- *
1405
- * An object containing rich text which exposes methods to manipulate the text.
1406
- * This is generated from a selection, with a range created for each instance of text in the selection.
1407
- * For example, if a table is currently selected, a range will be created for each cell.
1408
- * If only part of the text of an element is selected, then only that part will be represented in the range.
1409
- */
1410
- export declare type RichtextRange = {
1411
- /**
1412
- * Formats all paragraphs that overlap the given bounds. The newline character separates text into
1413
- * distinct paragraphs. Newline separator is treated as the final character of each paragraph.
1414
- * All paragraphs that overlap the given bounds will be formatted in their entirety.
1415
- * @param bounds - The region of text overlapping the paragraphs to apply the formatting.
1416
- * @param formatting - The formatting to apply to the paragraph(s).
1417
- */
1418
- formatParagraph(bounds: Bounds, formatting: RichtextFormatting): void;
1419
- /**
1420
- * Formats a given region of rich text with inline formatting.
1421
- * @param bounds - The region of text to apply the formatting.
1422
- * @param formatting - The inline formatting to apply to the region of text.
1423
- */
1424
- formatText(bounds: Bounds, formatting: InlineFormatting): void;
1425
- /**
1426
- * Appends characters to the rich text range.
1427
- * Appended characters can be formatted with inline formatting properties.
1428
- * @param characters - The characters to append to the rich text range.
1429
- * @param formatting - The inline formatting to apply to the appended text.
1430
- */
1431
- appendText(
1432
- characters: string,
1433
- formatting?: InlineFormatting
1434
- ): {
1435
- bounds: Bounds;
1436
- };
1437
- /**
1438
- * Replaces a region of the rich text range with the specified characters.
1439
- * Replaced characters can be formatted with inline formatting properties.
1440
- * @param bounds - The region of text to be replaced.
1441
- * @param characters - The replacement characters.
1442
- * @param formatting - The inline formatting to apply to the replaced text.
1443
- */
1444
- replaceText(
1445
- bounds: Bounds,
1446
- characters: string,
1447
- formatting?: InlineFormatting
1448
- ): {
1449
- bounds: Bounds;
1450
- };
1451
- /**
1452
- * Returns the current state of the rich text range as plain text.
1453
- *
1454
- * @remarks
1455
- * If this range is a draft, this includes any changes to the text that have not been committed.
1456
- */
1457
- readPlaintext(): string;
1458
- /**
1459
- * Returns the current state of the rich text range as an array of text regions.
1460
- * Each region is an object that contains the text itself and its formatting.
1461
- *
1462
- * @remarks
1463
- * If this range is a draft, this array includes any changes to the text that have not been committed.
1464
- */
1465
- readTextRegions(): TextRegion[];
1466
- };
1467
-
1468
- /**
1469
- * @beta
1137
+ * @public
1470
1138
  * An alias for the DesignSelection interface, providing access to design selection related functionality
1471
1139
  */
1472
1140
  export declare const selection: DesignSelection;
1473
1141
 
1474
1142
  /**
1475
- * @beta
1143
+ * @public
1476
1144
  * Information about the user's selection. To access the selected content, call the `read` method.
1477
1145
  */
1478
1146
  export declare interface SelectionEvent<Scope extends SelectionScope> {
@@ -1507,17 +1175,13 @@ export declare interface SelectionEvent<Scope extends SelectionScope> {
1507
1175
  }
1508
1176
 
1509
1177
  /**
1510
- * @beta
1178
+ * @public
1511
1179
  * The type of content that apps can detect selection changes on.
1512
1180
  */
1513
- export declare type SelectionScope =
1514
- | "plaintext"
1515
- | "image"
1516
- | "video"
1517
- | "richtext";
1181
+ export declare type SelectionScope = "plaintext" | "image" | "video";
1518
1182
 
1519
1183
  /**
1520
- * @beta
1184
+ * @public
1521
1185
  * The selected content.
1522
1186
  *
1523
1187
  * @remarks
@@ -1551,10 +1215,6 @@ export declare type SelectionValue<Scope extends SelectionScope> = {
1551
1215
  */
1552
1216
  ref: VideoRef;
1553
1217
  };
1554
- /**
1555
- * The selected content when {@link SelectionScope} is `"richtext"`.
1556
- */
1557
- ["richtext"]: RichtextRange;
1558
1218
  }[Scope];
1559
1219
 
1560
1220
  /**
@@ -1671,39 +1331,6 @@ export declare type TextAttributes = {
1671
1331
  decoration?: "none" | "underline";
1672
1332
  };
1673
1333
 
1674
- /**
1675
- * @beta
1676
- */
1677
- declare type TextBox = {
1678
- /**
1679
- * The width of the element. This must be an integer between 0 and 32767.
1680
- */
1681
- width?: number;
1682
- /**
1683
- * The distance from the top edge of the container.
1684
- *
1685
- * @remarks
1686
- * This must be an integer between -32768 and 32767. This property doesn't have
1687
- * any effect if the app element only contains a single element.
1688
- */
1689
- top: number;
1690
- /**
1691
- * The distance from the left edge of the container.
1692
- *
1693
- * @remarks
1694
- * This must be an integer between -32768 and 32767. This property doesn't have
1695
- * any effect if the app element only contains a single element.
1696
- */
1697
- left: number;
1698
- /**
1699
- * The rotation of the element, in degrees.
1700
- *
1701
- * @remarks
1702
- * This must be an integer between -180 and 180.
1703
- */
1704
- rotation?: number;
1705
- };
1706
-
1707
1334
  /**
1708
1335
  * @public
1709
1336
  * Options for defining the drag-and-drop behavior of a text element.
@@ -1737,26 +1364,6 @@ export declare type TextDragConfig = {
1737
1364
  * @defaultValue 'none'
1738
1365
  */
1739
1366
  decoration?: "none" | "underline";
1740
- /**
1741
- * @beta
1742
- * A unique identifier that references a font asset in Canva's backend.
1743
- */
1744
- fontRef?: FontRef;
1745
- };
1746
-
1747
- /**
1748
- * @beta
1749
- * A region of rich text.
1750
- */
1751
- export declare type TextRegion = {
1752
- /**
1753
- * The plain text content of the region.
1754
- */
1755
- text: string;
1756
- /**
1757
- * The formatting of the region.
1758
- */
1759
- formatting?: Partial<RichtextFormatting>;
1760
1367
  };
1761
1368
 
1762
1369
  /**
@@ -0,0 +1,19 @@
1
+ // Copyright 2023 Canva Inc. All Rights Reserved.
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ _export_star(require("./public"), exports);
7
+ function _export_star(from, to) {
8
+ Object.keys(from).forEach(function(k) {
9
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
10
+ Object.defineProperty(to, k, {
11
+ enumerable: true,
12
+ get: function() {
13
+ return from[k];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ return from;
19
+ }
@@ -0,0 +1,2 @@
1
+ // Copyright 2023 Canva Inc. All Rights Reserved.
2
+ export * from './public';
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@canva/design",
3
- "version": "1.10.0-beta.1",
3
+ "version": "1.10.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
8
  "@canva/error": "^1.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
+ }
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- selection: function() {
13
- return selection;
14
- },
15
- addNativeElement: function() {
16
- return addNativeElement;
17
- },
18
- createRichtextRange: function() {
19
- return createRichtextRange;
20
- },
21
- readContent: function() {
22
- return readContent;
23
- }
24
- });
25
- _export_star(require("./public"), exports);
26
- function _export_star(from, to) {
27
- Object.keys(from).forEach(function(k) {
28
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
29
- Object.defineProperty(to, k, {
30
- enumerable: true,
31
- get: function() {
32
- return from[k];
33
- }
34
- });
35
- }
36
- });
37
- return from;
38
- }
39
- const { canva } = window;
40
- const selection = canva.designInteraction.selection;
41
- function addNativeElement(element) {
42
- return canva.designInteraction.addNativeElement(element);
43
- }
44
- function createRichtextRange() {
45
- return canva.designInteraction.createRichtextRange();
46
- }
47
- function readContent(options, callback) {
48
- return canva.designInteraction.readContent(options, callback);
49
- }
@@ -1,26 +0,0 @@
1
- const { canva } = window;
2
- /**
3
- * @beta
4
- * An alias for the DesignSelection interface, providing access to design selection related functionality
5
- */ export const selection = canva.designInteraction.selection;
6
- /**
7
- * @internal
8
- * @param element
9
- */ export function addNativeElement(element) {
10
- return canva.designInteraction.addNativeElement(element);
11
- }
12
- /**
13
- * @beta
14
- * Creates a new RichtextRange object, which contains methods to manipulate text.
15
- */ export function createRichtextRange() {
16
- return canva.designInteraction.createRichtextRange();
17
- }
18
- /**
19
- * @beta
20
- * Reads content of the specified type from the user's design.
21
- * @param options - Options for configuring how a design is read.
22
- * @param callback - A callback for operating on the queried content.
23
- */ export function readContent(options, callback) {
24
- return canva.designInteraction.readContent(options, callback);
25
- }
26
- export * from './public';