@canva/design 1.9.0 → 1.10.0-beta.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.
package/{index.d.ts → beta.d.ts}
RENAMED
|
@@ -5,6 +5,20 @@
|
|
|
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
|
+
|
|
8
22
|
/**
|
|
9
23
|
* @public
|
|
10
24
|
* Adds a native element to the user's design.
|
|
@@ -30,6 +44,23 @@ export declare function addPage(opts?: {
|
|
|
30
44
|
title?: string;
|
|
31
45
|
}): Promise<void>;
|
|
32
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @public
|
|
49
|
+
* Describes any alt-text that will be added for a11y.
|
|
50
|
+
*/
|
|
51
|
+
export declare type AltText = {
|
|
52
|
+
/**
|
|
53
|
+
* The text that will appear as alt-text.
|
|
54
|
+
*/
|
|
55
|
+
text: string;
|
|
56
|
+
/**
|
|
57
|
+
* An optional property that will determine whether text is shown in just the editor or both editor and view mode.
|
|
58
|
+
* If set to true, alt-text will only be rendered inside the editor.
|
|
59
|
+
* If set to false or omitted, alt-text will be rendered in both the editor and in view only mode.
|
|
60
|
+
*/
|
|
61
|
+
decorative: boolean | undefined;
|
|
62
|
+
};
|
|
63
|
+
|
|
33
64
|
/**
|
|
34
65
|
* @public
|
|
35
66
|
* A callback that runs when an app element's data is created or updated,
|
|
@@ -151,6 +182,24 @@ export declare type AudioTrack = {
|
|
|
151
182
|
ref: AudioRef;
|
|
152
183
|
};
|
|
153
184
|
|
|
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
|
+
|
|
154
203
|
/**
|
|
155
204
|
* @public
|
|
156
205
|
* The dimensions, position, and rotation of an element.
|
|
@@ -160,6 +209,31 @@ export declare type AudioTrack = {
|
|
|
160
209
|
*/
|
|
161
210
|
export declare type Box = Position & (WidthAndHeight | Width | Height);
|
|
162
211
|
|
|
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
|
+
|
|
163
237
|
declare type CommonImageDragConfig = {
|
|
164
238
|
/**
|
|
165
239
|
* The type of element.
|
|
@@ -198,6 +272,20 @@ export declare interface ContentDraft<T> {
|
|
|
198
272
|
save(): Promise<void>;
|
|
199
273
|
}
|
|
200
274
|
|
|
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
|
+
|
|
201
289
|
/**
|
|
202
290
|
* @public
|
|
203
291
|
* Represents X and Y coordinates.
|
|
@@ -213,6 +301,12 @@ export declare type Coordinates = {
|
|
|
213
301
|
y: number;
|
|
214
302
|
};
|
|
215
303
|
|
|
304
|
+
/**
|
|
305
|
+
* @beta
|
|
306
|
+
* Creates a new RichtextRange object, which contains methods to manipulate text.
|
|
307
|
+
*/
|
|
308
|
+
export declare function createRichtextRange(): RichtextRange;
|
|
309
|
+
|
|
216
310
|
/**
|
|
217
311
|
* @public
|
|
218
312
|
* Provides methods for interacting with design overlay
|
|
@@ -231,7 +325,7 @@ export declare type DesignOverlay = {
|
|
|
231
325
|
};
|
|
232
326
|
|
|
233
327
|
/**
|
|
234
|
-
* @
|
|
328
|
+
* @beta
|
|
235
329
|
* Provides methods for interacting with the user's selected content, such as images or text.
|
|
236
330
|
*/
|
|
237
331
|
export declare type DesignSelection = {
|
|
@@ -312,6 +406,14 @@ export declare type DragStartEvent<E extends Element> = Pick<
|
|
|
312
406
|
currentTarget: E;
|
|
313
407
|
};
|
|
314
408
|
|
|
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
|
+
|
|
315
417
|
/**
|
|
316
418
|
* @public
|
|
317
419
|
* Options for making an `HTMLElement` draggable.
|
|
@@ -646,6 +748,50 @@ export declare function initAppElement<A extends AppElementData>(
|
|
|
646
748
|
appElementConfig: AppElementClientConfiguration<A>
|
|
647
749
|
): AppElementClient<A>;
|
|
648
750
|
|
|
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
|
+
|
|
649
795
|
/**
|
|
650
796
|
* @public
|
|
651
797
|
* A native element.
|
|
@@ -765,6 +911,10 @@ export declare type NativeImageElement = {
|
|
|
765
911
|
* The type of element.
|
|
766
912
|
*/
|
|
767
913
|
type: "IMAGE";
|
|
914
|
+
/**
|
|
915
|
+
* An optional object to describe alt-text that may be applied to an image.
|
|
916
|
+
*/
|
|
917
|
+
altText?: AltText;
|
|
768
918
|
} & (
|
|
769
919
|
| {
|
|
770
920
|
/**
|
|
@@ -800,6 +950,34 @@ export declare type NativeImageElement = {
|
|
|
800
950
|
*/
|
|
801
951
|
export declare type NativeImageElementWithBox = NativeImageElement & Box;
|
|
802
952
|
|
|
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
|
+
|
|
803
981
|
/**
|
|
804
982
|
* @public
|
|
805
983
|
* An element that renders a vector shape.
|
|
@@ -863,6 +1041,23 @@ export declare type NativeSimpleElementWithBox = Exclude<
|
|
|
863
1041
|
NativeGroupElementWithBox
|
|
864
1042
|
>;
|
|
865
1043
|
|
|
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
|
+
|
|
866
1061
|
/**
|
|
867
1062
|
* @public
|
|
868
1063
|
* An element that renders text.
|
|
@@ -944,6 +1139,10 @@ export declare type NativeVideoElement = {
|
|
|
944
1139
|
* A unique identifier that references a video asset in Canva's backend.
|
|
945
1140
|
*/
|
|
946
1141
|
ref: VideoRef;
|
|
1142
|
+
/**
|
|
1143
|
+
* An optional object to describe alt-text that may be applied to a video.
|
|
1144
|
+
*/
|
|
1145
|
+
altText?: AltText;
|
|
947
1146
|
};
|
|
948
1147
|
|
|
949
1148
|
/**
|
|
@@ -1099,6 +1298,50 @@ declare type Position = {
|
|
|
1099
1298
|
*/
|
|
1100
1299
|
declare type Primitive = undefined | null | number | boolean | string;
|
|
1101
1300
|
|
|
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
|
+
|
|
1102
1345
|
/**
|
|
1103
1346
|
* @public
|
|
1104
1347
|
* Exports the user's design as one or more static files.
|
|
@@ -1109,13 +1352,127 @@ export declare function requestExport(
|
|
|
1109
1352
|
): Promise<ExportResponse>;
|
|
1110
1353
|
|
|
1111
1354
|
/**
|
|
1112
|
-
* @
|
|
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
|
|
1113
1470
|
* An alias for the DesignSelection interface, providing access to design selection related functionality
|
|
1114
1471
|
*/
|
|
1115
1472
|
export declare const selection: DesignSelection;
|
|
1116
1473
|
|
|
1117
1474
|
/**
|
|
1118
|
-
* @
|
|
1475
|
+
* @beta
|
|
1119
1476
|
* Information about the user's selection. To access the selected content, call the `read` method.
|
|
1120
1477
|
*/
|
|
1121
1478
|
export declare interface SelectionEvent<Scope extends SelectionScope> {
|
|
@@ -1150,13 +1507,17 @@ export declare interface SelectionEvent<Scope extends SelectionScope> {
|
|
|
1150
1507
|
}
|
|
1151
1508
|
|
|
1152
1509
|
/**
|
|
1153
|
-
* @
|
|
1510
|
+
* @beta
|
|
1154
1511
|
* The type of content that apps can detect selection changes on.
|
|
1155
1512
|
*/
|
|
1156
|
-
export declare type SelectionScope =
|
|
1513
|
+
export declare type SelectionScope =
|
|
1514
|
+
| "plaintext"
|
|
1515
|
+
| "image"
|
|
1516
|
+
| "video"
|
|
1517
|
+
| "richtext";
|
|
1157
1518
|
|
|
1158
1519
|
/**
|
|
1159
|
-
* @
|
|
1520
|
+
* @beta
|
|
1160
1521
|
* The selected content.
|
|
1161
1522
|
*
|
|
1162
1523
|
* @remarks
|
|
@@ -1190,6 +1551,10 @@ export declare type SelectionValue<Scope extends SelectionScope> = {
|
|
|
1190
1551
|
*/
|
|
1191
1552
|
ref: VideoRef;
|
|
1192
1553
|
};
|
|
1554
|
+
/**
|
|
1555
|
+
* The selected content when {@link SelectionScope} is `"richtext"`.
|
|
1556
|
+
*/
|
|
1557
|
+
["richtext"]: RichtextRange;
|
|
1193
1558
|
}[Scope];
|
|
1194
1559
|
|
|
1195
1560
|
/**
|
|
@@ -1306,6 +1671,39 @@ export declare type TextAttributes = {
|
|
|
1306
1671
|
decoration?: "none" | "underline";
|
|
1307
1672
|
};
|
|
1308
1673
|
|
|
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
|
+
|
|
1309
1707
|
/**
|
|
1310
1708
|
* @public
|
|
1311
1709
|
* Options for defining the drag-and-drop behavior of a text element.
|
|
@@ -1339,6 +1737,26 @@ export declare type TextDragConfig = {
|
|
|
1339
1737
|
* @defaultValue 'none'
|
|
1340
1738
|
*/
|
|
1341
1739
|
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>;
|
|
1342
1760
|
};
|
|
1343
1761
|
|
|
1344
1762
|
/**
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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';
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canva/design",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0-beta.1",
|
|
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/
|
|
11
|
-
"module": "./lib/esm/sdk/design/
|
|
10
|
+
"main": "./lib/cjs/sdk/design/beta.js",
|
|
11
|
+
"module": "./lib/esm/sdk/design/beta.js",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"require": {
|
|
15
|
-
"types": "./
|
|
16
|
-
"default": "./lib/cjs/sdk/design/
|
|
15
|
+
"types": "./beta.d.ts",
|
|
16
|
+
"default": "./lib/cjs/sdk/design/beta.js"
|
|
17
17
|
},
|
|
18
18
|
"import": {
|
|
19
|
-
"types": "./
|
|
20
|
-
"default": "./lib/esm/sdk/design/
|
|
19
|
+
"types": "./beta.d.ts",
|
|
20
|
+
"default": "./lib/esm/sdk/design/beta.js"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
"typings": "./
|
|
25
|
-
}
|
|
24
|
+
"typings": "./beta.d.ts"
|
|
25
|
+
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|