@canva/design 2.6.0 → 2.6.1-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} +115 -5
- package/lib/cjs/sdk/design/{index.js → beta.js} +10 -2
- package/lib/cjs/sdk/design/fake/fake_design_interaction_client.js +205 -1
- package/lib/cjs/sdk/design/test/beta.js +18 -0
- package/lib/esm/sdk/design/{index.js → beta.js} +3 -1
- package/lib/esm/sdk/design/fake/fake_design_interaction_client.js +205 -1
- package/lib/esm/sdk/design/test/beta.js +1 -0
- package/package.json +10 -10
- /package/test/{index.d.ts → beta.d.ts} +0 -0
package/{index.d.ts → beta.d.ts}
RENAMED
|
@@ -348,11 +348,39 @@ export declare interface ContentDraft<T> {
|
|
|
348
348
|
save(): Promise<void>;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
+
/**
|
|
352
|
+
* @beta
|
|
353
|
+
* Object for interacting with fill content (images/videos).
|
|
354
|
+
*/
|
|
355
|
+
export declare type ContentFill = (
|
|
356
|
+
| Omit<ImageFill, "altText">
|
|
357
|
+
| Omit<VideoFill, "altText">
|
|
358
|
+
) & {
|
|
359
|
+
/**
|
|
360
|
+
* Indicates whether the fill object has been deleted.
|
|
361
|
+
*/
|
|
362
|
+
deleted: boolean;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* @beta
|
|
367
|
+
* Session for reading and updating fill content in a user's design.
|
|
368
|
+
*/
|
|
369
|
+
export declare interface ContentFillSession {
|
|
370
|
+
readonly contents: readonly ContentFill[];
|
|
371
|
+
sync(): Promise<void>;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* @beta
|
|
376
|
+
*/
|
|
377
|
+
export declare type ContentType = "richtext" | "fill";
|
|
378
|
+
|
|
351
379
|
/**
|
|
352
380
|
* @public
|
|
353
381
|
* A type of content that can be read from a user's design.
|
|
354
382
|
*/
|
|
355
|
-
|
|
383
|
+
declare type ContentType_2 = "richtext";
|
|
356
384
|
|
|
357
385
|
/**
|
|
358
386
|
* @public
|
|
@@ -1792,6 +1820,15 @@ export declare namespace DesignEditing {
|
|
|
1792
1820
|
| EmbedElement
|
|
1793
1821
|
| TextElement
|
|
1794
1822
|
| UnsupportedElement;
|
|
1823
|
+
/**
|
|
1824
|
+
* @public
|
|
1825
|
+
* An element state that can be inserted into a page.
|
|
1826
|
+
*/
|
|
1827
|
+
export type InsertableElementState =
|
|
1828
|
+
| RectElementState
|
|
1829
|
+
| ShapeElementState
|
|
1830
|
+
| EmbedElementState
|
|
1831
|
+
| TextElementState;
|
|
1795
1832
|
/**
|
|
1796
1833
|
* @public
|
|
1797
1834
|
* A list of elements.
|
|
@@ -1816,6 +1853,10 @@ export declare namespace DesignEditing {
|
|
|
1816
1853
|
ref: AbsoluteElement | undefined,
|
|
1817
1854
|
state: RectElementState,
|
|
1818
1855
|
): RectElement;
|
|
1856
|
+
insertBefore(
|
|
1857
|
+
ref: AbsoluteElement | undefined,
|
|
1858
|
+
state: InsertableElementState,
|
|
1859
|
+
): AbsoluteElement;
|
|
1819
1860
|
insertAfter(
|
|
1820
1861
|
ref: AbsoluteElement | undefined,
|
|
1821
1862
|
state: EmbedElementState,
|
|
@@ -1832,6 +1873,10 @@ export declare namespace DesignEditing {
|
|
|
1832
1873
|
ref: AbsoluteElement | undefined,
|
|
1833
1874
|
state: RectElementState,
|
|
1834
1875
|
): RectElement;
|
|
1876
|
+
insertAfter(
|
|
1877
|
+
ref: AbsoluteElement | undefined,
|
|
1878
|
+
state: InsertableElementState,
|
|
1879
|
+
): AbsoluteElement;
|
|
1835
1880
|
}
|
|
1836
1881
|
|
|
1837
1882
|
/**
|
|
@@ -1894,6 +1939,40 @@ export declare type DesignElement =
|
|
|
1894
1939
|
| RichtextElement
|
|
1895
1940
|
| TableElement;
|
|
1896
1941
|
|
|
1942
|
+
/**
|
|
1943
|
+
* @beta
|
|
1944
|
+
* Information about the design.
|
|
1945
|
+
*/
|
|
1946
|
+
export declare type DesignMetadata = {
|
|
1947
|
+
/**
|
|
1948
|
+
* The title of the user's design.
|
|
1949
|
+
* @remarks
|
|
1950
|
+
* This is optional and will be `undefined` if the user hasn't set a title.
|
|
1951
|
+
*/
|
|
1952
|
+
title?: string;
|
|
1953
|
+
/**
|
|
1954
|
+
* The default dimensions that a new page will have when it is added to a design.
|
|
1955
|
+
* It is possible for a user to resize a page without resizing the entire design, e.g. by clicking
|
|
1956
|
+
* "Expand to Whiteboard". However, there will always be a single set of default dimensions for a
|
|
1957
|
+
* design that is applied whenever a new page is created.
|
|
1958
|
+
* @remarks
|
|
1959
|
+
* This is optional and will be `undefined` if the design is unbounded (e.g. Whiteboard or Doc).
|
|
1960
|
+
*/
|
|
1961
|
+
defaultPageDimensions?: PageDimensions;
|
|
1962
|
+
/**
|
|
1963
|
+
* The information associated with each page of the design.
|
|
1964
|
+
* @remarks
|
|
1965
|
+
* The order of pages is not guaranteed.
|
|
1966
|
+
*/
|
|
1967
|
+
pageMetadata: Iterable<PageContext>;
|
|
1968
|
+
/**
|
|
1969
|
+
* The duration of the whole design in seconds.
|
|
1970
|
+
* @remarks
|
|
1971
|
+
* This is the precise value, which differs from what is displayed in the UI as duration in Canva UI is formatted differently.
|
|
1972
|
+
*/
|
|
1973
|
+
durationInSeconds: number;
|
|
1974
|
+
};
|
|
1975
|
+
|
|
1897
1976
|
/**
|
|
1898
1977
|
* @public
|
|
1899
1978
|
* A callback for reading and updating part of a design.
|
|
@@ -2002,21 +2081,30 @@ export declare type DragStartEvent<E extends Element> = Pick<
|
|
|
2002
2081
|
* @param callback - A callback for operating on the read content.
|
|
2003
2082
|
*/
|
|
2004
2083
|
export declare const editContent: (
|
|
2005
|
-
options:
|
|
2006
|
-
callback:
|
|
2084
|
+
options: EditContentOptions_2,
|
|
2085
|
+
callback: EditContentCallback_2,
|
|
2007
2086
|
) => Promise<void>;
|
|
2008
2087
|
|
|
2009
2088
|
/**
|
|
2010
|
-
* @
|
|
2089
|
+
* @beta
|
|
2011
2090
|
* A callback for reading and updating the requested design content.
|
|
2012
2091
|
* @param session - The result of reading the content in the design.
|
|
2013
2092
|
*/
|
|
2014
2093
|
export declare type EditContentCallback = (
|
|
2015
|
-
session: RichtextContentSession,
|
|
2094
|
+
session: RichtextContentSession | ContentFillSession,
|
|
2016
2095
|
) => Promise<void> | void;
|
|
2017
2096
|
|
|
2018
2097
|
/**
|
|
2019
2098
|
* @public
|
|
2099
|
+
* A callback for reading and updating the requested design content.
|
|
2100
|
+
* @param session - The result of reading the content in the design.
|
|
2101
|
+
*/
|
|
2102
|
+
declare type EditContentCallback_2 = (
|
|
2103
|
+
session: RichtextContentSession,
|
|
2104
|
+
) => Promise<void> | void;
|
|
2105
|
+
|
|
2106
|
+
/**
|
|
2107
|
+
* @beta
|
|
2020
2108
|
* Options for configuring how the design content is read.
|
|
2021
2109
|
*/
|
|
2022
2110
|
export declare type EditContentOptions = {
|
|
@@ -2026,6 +2114,17 @@ export declare type EditContentOptions = {
|
|
|
2026
2114
|
contentType: ContentType;
|
|
2027
2115
|
} & ContextOptions;
|
|
2028
2116
|
|
|
2117
|
+
/**
|
|
2118
|
+
* @public
|
|
2119
|
+
* Options for configuring how the design content is read.
|
|
2120
|
+
*/
|
|
2121
|
+
declare type EditContentOptions_2 = {
|
|
2122
|
+
/**
|
|
2123
|
+
* The type of content to edit from the user's design
|
|
2124
|
+
*/
|
|
2125
|
+
contentType: ContentType_2;
|
|
2126
|
+
} & ContextOptions;
|
|
2127
|
+
|
|
2029
2128
|
/**
|
|
2030
2129
|
* @public
|
|
2031
2130
|
* Elements targeting a cursor are a subset of the base Element
|
|
@@ -2299,6 +2398,12 @@ export declare const getDefaultPageDimensions: () => Promise<
|
|
|
2299
2398
|
Dimensions | undefined
|
|
2300
2399
|
>;
|
|
2301
2400
|
|
|
2401
|
+
/**
|
|
2402
|
+
* @beta
|
|
2403
|
+
* Retrieves information about the design.
|
|
2404
|
+
*/
|
|
2405
|
+
export declare const getDesignMetadata: () => Promise<DesignMetadata>;
|
|
2406
|
+
|
|
2302
2407
|
/**
|
|
2303
2408
|
* @public
|
|
2304
2409
|
* Retrieves a signed JWT that contains the Design ID, App ID and User ID.
|
|
@@ -3321,6 +3426,11 @@ export declare type TextDragConfig = {
|
|
|
3321
3426
|
* @defaultValue "none"
|
|
3322
3427
|
*/
|
|
3323
3428
|
decoration?: "none" | "underline";
|
|
3429
|
+
/**
|
|
3430
|
+
* @beta
|
|
3431
|
+
* A unique identifier that points to a font asset in Canva's backend.
|
|
3432
|
+
*/
|
|
3433
|
+
fontRef?: FontRef;
|
|
3324
3434
|
};
|
|
3325
3435
|
|
|
3326
3436
|
/**
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
Object.defineProperty(exports, "getDesignMetadata", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getDesignMetadata;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
5
11
|
_export_star(require("./public"), exports);
|
|
6
12
|
function _export_star(from, to) {
|
|
7
13
|
Object.keys(from).forEach(function(k) {
|
|
@@ -17,4 +23,6 @@ function _export_star(from, to) {
|
|
|
17
23
|
return from;
|
|
18
24
|
}
|
|
19
25
|
var _window___canva___sdkRegistration, _window___canva__;
|
|
20
|
-
|
|
26
|
+
const { canva_sdk } = window;
|
|
27
|
+
const getDesignMetadata = canva_sdk.design.v2.designInteraction.getDesignMetadata;
|
|
28
|
+
(_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.6.1', 'beta');
|
|
@@ -112,7 +112,21 @@ class FakeDesignInteractionClient {
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
async openDesign(options, callback) {
|
|
115
|
-
|
|
115
|
+
await this.delay();
|
|
116
|
+
await callback({
|
|
117
|
+
page: fakePage,
|
|
118
|
+
sync: async ()=>{
|
|
119
|
+
await this.delay();
|
|
120
|
+
},
|
|
121
|
+
helpers: {
|
|
122
|
+
elementStateBuilder: fakeElementStateBuilder,
|
|
123
|
+
group: fakeAsyncOperations.group,
|
|
124
|
+
ungroup: fakeAsyncOperations.ungroup,
|
|
125
|
+
snapshot: ()=>{
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
116
130
|
}
|
|
117
131
|
constructor(delay){
|
|
118
132
|
this.delay = delay;
|
|
@@ -160,3 +174,193 @@ const fakePageDimensions = {
|
|
|
160
174
|
width: 800,
|
|
161
175
|
height: 600
|
|
162
176
|
};
|
|
177
|
+
const fakeFill = {
|
|
178
|
+
mediaContainer: {
|
|
179
|
+
ref: undefined,
|
|
180
|
+
set (state) {}
|
|
181
|
+
},
|
|
182
|
+
colorContainer: {
|
|
183
|
+
ref: {
|
|
184
|
+
type: 'solid',
|
|
185
|
+
color: '#000000'
|
|
186
|
+
},
|
|
187
|
+
set (state) {}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const fakeColorContainer = {
|
|
191
|
+
ref: {
|
|
192
|
+
type: 'solid',
|
|
193
|
+
color: '#000000'
|
|
194
|
+
},
|
|
195
|
+
set (state) {}
|
|
196
|
+
};
|
|
197
|
+
const fakeElementList = {
|
|
198
|
+
forEach (callback) {},
|
|
199
|
+
delete (item) {},
|
|
200
|
+
moveAfter (ref, item) {},
|
|
201
|
+
moveBefore (ref, item) {},
|
|
202
|
+
toArray () {
|
|
203
|
+
return [
|
|
204
|
+
fakeRectElement,
|
|
205
|
+
fakeShapeElement
|
|
206
|
+
];
|
|
207
|
+
},
|
|
208
|
+
count () {
|
|
209
|
+
return 0;
|
|
210
|
+
},
|
|
211
|
+
filter (filter) {},
|
|
212
|
+
insertAfter (ref, state) {
|
|
213
|
+
return fakeRectElement;
|
|
214
|
+
},
|
|
215
|
+
insertBefore (ref, state) {
|
|
216
|
+
return fakeRectElement;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const fakePage = {
|
|
220
|
+
type: 'absolute',
|
|
221
|
+
locked: false,
|
|
222
|
+
dimensions: fakePageDimensions,
|
|
223
|
+
background: fakeFill,
|
|
224
|
+
elements: fakeElementList
|
|
225
|
+
};
|
|
226
|
+
const fakeElement = {
|
|
227
|
+
top: 0,
|
|
228
|
+
left: 0,
|
|
229
|
+
rotation: 0,
|
|
230
|
+
transparency: 0,
|
|
231
|
+
locked: true,
|
|
232
|
+
width: 100,
|
|
233
|
+
height: 100
|
|
234
|
+
};
|
|
235
|
+
const fakeRectElement = {
|
|
236
|
+
...fakeElement,
|
|
237
|
+
type: 'rect',
|
|
238
|
+
fill: fakeFill,
|
|
239
|
+
stroke: {
|
|
240
|
+
weight: 10,
|
|
241
|
+
colorContainer: fakeColorContainer
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
const fakeShapeElement = {
|
|
245
|
+
...fakeElement,
|
|
246
|
+
type: 'shape',
|
|
247
|
+
viewBox: {
|
|
248
|
+
top: 0,
|
|
249
|
+
left: 0,
|
|
250
|
+
width: 100,
|
|
251
|
+
height: 100
|
|
252
|
+
},
|
|
253
|
+
paths: {
|
|
254
|
+
count: ()=>0,
|
|
255
|
+
toArray: ()=>[],
|
|
256
|
+
forEach: (callback)=>{},
|
|
257
|
+
filter: (filter)=>[]
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const fakeEmbedElement = {
|
|
261
|
+
...fakeElement,
|
|
262
|
+
type: 'embed',
|
|
263
|
+
url: 'https://canva.dev/docs/apps/testing/'
|
|
264
|
+
};
|
|
265
|
+
const fakeTextElement = {
|
|
266
|
+
...fakeElement,
|
|
267
|
+
type: 'text',
|
|
268
|
+
text: fakeRichtextRange
|
|
269
|
+
};
|
|
270
|
+
const fakeElementStateBuilder = {
|
|
271
|
+
createEmbedElement (opts) {
|
|
272
|
+
return fakeEmbedElement;
|
|
273
|
+
},
|
|
274
|
+
createRectElement (opts) {
|
|
275
|
+
return {
|
|
276
|
+
...fakeRectElement,
|
|
277
|
+
fill: {
|
|
278
|
+
colorContainer: {
|
|
279
|
+
type: 'solid',
|
|
280
|
+
color: '#000000'
|
|
281
|
+
},
|
|
282
|
+
mediaContainer: undefined
|
|
283
|
+
},
|
|
284
|
+
stroke: {
|
|
285
|
+
weight: 10,
|
|
286
|
+
colorContainer: {
|
|
287
|
+
type: 'solid',
|
|
288
|
+
color: '#000000'
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
},
|
|
293
|
+
createRichtextRange () {
|
|
294
|
+
return fakeRichtextRange;
|
|
295
|
+
},
|
|
296
|
+
createShapeElement (opts) {
|
|
297
|
+
return {
|
|
298
|
+
...fakeShapeElement,
|
|
299
|
+
paths: []
|
|
300
|
+
};
|
|
301
|
+
},
|
|
302
|
+
createTextElement (opts) {
|
|
303
|
+
return {
|
|
304
|
+
...fakeTextElement,
|
|
305
|
+
text: {
|
|
306
|
+
regions: []
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
const fakeAsyncOperations = {
|
|
312
|
+
async group () {
|
|
313
|
+
const fakeGroupElement = {
|
|
314
|
+
top: 0,
|
|
315
|
+
left: 0,
|
|
316
|
+
width: 100,
|
|
317
|
+
height: 100,
|
|
318
|
+
locked: false,
|
|
319
|
+
rotation: 0,
|
|
320
|
+
transparency: 0,
|
|
321
|
+
type: 'group',
|
|
322
|
+
contents: {
|
|
323
|
+
count: ()=>0,
|
|
324
|
+
toArray: ()=>[],
|
|
325
|
+
forEach: (callback)=>{},
|
|
326
|
+
filter: (filter)=>[]
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
return fakeGroupElement;
|
|
330
|
+
},
|
|
331
|
+
async ungroup () {
|
|
332
|
+
const fakeRectElement = {
|
|
333
|
+
top: 0,
|
|
334
|
+
left: 0,
|
|
335
|
+
width: 100,
|
|
336
|
+
height: 100,
|
|
337
|
+
locked: false,
|
|
338
|
+
rotation: 0,
|
|
339
|
+
transparency: 0,
|
|
340
|
+
type: 'rect',
|
|
341
|
+
fill: {
|
|
342
|
+
mediaContainer: {
|
|
343
|
+
set () {},
|
|
344
|
+
ref: undefined
|
|
345
|
+
},
|
|
346
|
+
colorContainer: {
|
|
347
|
+
set () {},
|
|
348
|
+
ref: undefined
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
stroke: {
|
|
352
|
+
weight: 10,
|
|
353
|
+
colorContainer: {
|
|
354
|
+
set () {},
|
|
355
|
+
ref: {
|
|
356
|
+
type: 'solid',
|
|
357
|
+
color: '#000000'
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
return [
|
|
363
|
+
fakeRectElement
|
|
364
|
+
];
|
|
365
|
+
}
|
|
366
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./index"), 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
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
var _window___canva___sdkRegistration, _window___canva__;
|
|
2
|
+
const { canva_sdk } = window;
|
|
3
|
+
export const getDesignMetadata = canva_sdk.design.v2.designInteraction.getDesignMetadata;
|
|
2
4
|
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.6.
|
|
5
|
+
(_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.6.1', 'beta');
|
|
@@ -102,7 +102,21 @@ export class FakeDesignInteractionClient {
|
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
async openDesign(options, callback) {
|
|
105
|
-
|
|
105
|
+
await this.delay();
|
|
106
|
+
await callback({
|
|
107
|
+
page: fakePage,
|
|
108
|
+
sync: async ()=>{
|
|
109
|
+
await this.delay();
|
|
110
|
+
},
|
|
111
|
+
helpers: {
|
|
112
|
+
elementStateBuilder: fakeElementStateBuilder,
|
|
113
|
+
group: fakeAsyncOperations.group,
|
|
114
|
+
ungroup: fakeAsyncOperations.ungroup,
|
|
115
|
+
snapshot: ()=>{
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
106
120
|
}
|
|
107
121
|
constructor(delay){
|
|
108
122
|
this.delay = delay;
|
|
@@ -150,3 +164,193 @@ const fakePageDimensions = {
|
|
|
150
164
|
width: 800,
|
|
151
165
|
height: 600
|
|
152
166
|
};
|
|
167
|
+
const fakeFill = {
|
|
168
|
+
mediaContainer: {
|
|
169
|
+
ref: undefined,
|
|
170
|
+
set (state) {}
|
|
171
|
+
},
|
|
172
|
+
colorContainer: {
|
|
173
|
+
ref: {
|
|
174
|
+
type: 'solid',
|
|
175
|
+
color: '#000000'
|
|
176
|
+
},
|
|
177
|
+
set (state) {}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const fakeColorContainer = {
|
|
181
|
+
ref: {
|
|
182
|
+
type: 'solid',
|
|
183
|
+
color: '#000000'
|
|
184
|
+
},
|
|
185
|
+
set (state) {}
|
|
186
|
+
};
|
|
187
|
+
const fakeElementList = {
|
|
188
|
+
forEach (callback) {},
|
|
189
|
+
delete (item) {},
|
|
190
|
+
moveAfter (ref, item) {},
|
|
191
|
+
moveBefore (ref, item) {},
|
|
192
|
+
toArray () {
|
|
193
|
+
return [
|
|
194
|
+
fakeRectElement,
|
|
195
|
+
fakeShapeElement
|
|
196
|
+
];
|
|
197
|
+
},
|
|
198
|
+
count () {
|
|
199
|
+
return 0;
|
|
200
|
+
},
|
|
201
|
+
filter (filter) {},
|
|
202
|
+
insertAfter (ref, state) {
|
|
203
|
+
return fakeRectElement;
|
|
204
|
+
},
|
|
205
|
+
insertBefore (ref, state) {
|
|
206
|
+
return fakeRectElement;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const fakePage = {
|
|
210
|
+
type: 'absolute',
|
|
211
|
+
locked: false,
|
|
212
|
+
dimensions: fakePageDimensions,
|
|
213
|
+
background: fakeFill,
|
|
214
|
+
elements: fakeElementList
|
|
215
|
+
};
|
|
216
|
+
const fakeElement = {
|
|
217
|
+
top: 0,
|
|
218
|
+
left: 0,
|
|
219
|
+
rotation: 0,
|
|
220
|
+
transparency: 0,
|
|
221
|
+
locked: true,
|
|
222
|
+
width: 100,
|
|
223
|
+
height: 100
|
|
224
|
+
};
|
|
225
|
+
const fakeRectElement = {
|
|
226
|
+
...fakeElement,
|
|
227
|
+
type: 'rect',
|
|
228
|
+
fill: fakeFill,
|
|
229
|
+
stroke: {
|
|
230
|
+
weight: 10,
|
|
231
|
+
colorContainer: fakeColorContainer
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const fakeShapeElement = {
|
|
235
|
+
...fakeElement,
|
|
236
|
+
type: 'shape',
|
|
237
|
+
viewBox: {
|
|
238
|
+
top: 0,
|
|
239
|
+
left: 0,
|
|
240
|
+
width: 100,
|
|
241
|
+
height: 100
|
|
242
|
+
},
|
|
243
|
+
paths: {
|
|
244
|
+
count: ()=>0,
|
|
245
|
+
toArray: ()=>[],
|
|
246
|
+
forEach: (callback)=>{},
|
|
247
|
+
filter: (filter)=>[]
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
const fakeEmbedElement = {
|
|
251
|
+
...fakeElement,
|
|
252
|
+
type: 'embed',
|
|
253
|
+
url: 'https://canva.dev/docs/apps/testing/'
|
|
254
|
+
};
|
|
255
|
+
const fakeTextElement = {
|
|
256
|
+
...fakeElement,
|
|
257
|
+
type: 'text',
|
|
258
|
+
text: fakeRichtextRange
|
|
259
|
+
};
|
|
260
|
+
const fakeElementStateBuilder = {
|
|
261
|
+
createEmbedElement (opts) {
|
|
262
|
+
return fakeEmbedElement;
|
|
263
|
+
},
|
|
264
|
+
createRectElement (opts) {
|
|
265
|
+
return {
|
|
266
|
+
...fakeRectElement,
|
|
267
|
+
fill: {
|
|
268
|
+
colorContainer: {
|
|
269
|
+
type: 'solid',
|
|
270
|
+
color: '#000000'
|
|
271
|
+
},
|
|
272
|
+
mediaContainer: undefined
|
|
273
|
+
},
|
|
274
|
+
stroke: {
|
|
275
|
+
weight: 10,
|
|
276
|
+
colorContainer: {
|
|
277
|
+
type: 'solid',
|
|
278
|
+
color: '#000000'
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
},
|
|
283
|
+
createRichtextRange () {
|
|
284
|
+
return fakeRichtextRange;
|
|
285
|
+
},
|
|
286
|
+
createShapeElement (opts) {
|
|
287
|
+
return {
|
|
288
|
+
...fakeShapeElement,
|
|
289
|
+
paths: []
|
|
290
|
+
};
|
|
291
|
+
},
|
|
292
|
+
createTextElement (opts) {
|
|
293
|
+
return {
|
|
294
|
+
...fakeTextElement,
|
|
295
|
+
text: {
|
|
296
|
+
regions: []
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
const fakeAsyncOperations = {
|
|
302
|
+
async group () {
|
|
303
|
+
const fakeGroupElement = {
|
|
304
|
+
top: 0,
|
|
305
|
+
left: 0,
|
|
306
|
+
width: 100,
|
|
307
|
+
height: 100,
|
|
308
|
+
locked: false,
|
|
309
|
+
rotation: 0,
|
|
310
|
+
transparency: 0,
|
|
311
|
+
type: 'group',
|
|
312
|
+
contents: {
|
|
313
|
+
count: ()=>0,
|
|
314
|
+
toArray: ()=>[],
|
|
315
|
+
forEach: (callback)=>{},
|
|
316
|
+
filter: (filter)=>[]
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
return fakeGroupElement;
|
|
320
|
+
},
|
|
321
|
+
async ungroup () {
|
|
322
|
+
const fakeRectElement = {
|
|
323
|
+
top: 0,
|
|
324
|
+
left: 0,
|
|
325
|
+
width: 100,
|
|
326
|
+
height: 100,
|
|
327
|
+
locked: false,
|
|
328
|
+
rotation: 0,
|
|
329
|
+
transparency: 0,
|
|
330
|
+
type: 'rect',
|
|
331
|
+
fill: {
|
|
332
|
+
mediaContainer: {
|
|
333
|
+
set () {},
|
|
334
|
+
ref: undefined
|
|
335
|
+
},
|
|
336
|
+
colorContainer: {
|
|
337
|
+
set () {},
|
|
338
|
+
ref: undefined
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
stroke: {
|
|
342
|
+
weight: 10,
|
|
343
|
+
colorContainer: {
|
|
344
|
+
set () {},
|
|
345
|
+
ref: {
|
|
346
|
+
type: 'solid',
|
|
347
|
+
color: '#000000'
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
return [
|
|
353
|
+
fakeRectElement
|
|
354
|
+
];
|
|
355
|
+
}
|
|
356
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index';
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canva/design",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1-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": "^2.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
|
-
"types": "./
|
|
15
|
-
"require": "./lib/cjs/sdk/design/
|
|
16
|
-
"import": "./lib/esm/sdk/design/
|
|
14
|
+
"types": "./beta.d.ts",
|
|
15
|
+
"require": "./lib/cjs/sdk/design/beta.js",
|
|
16
|
+
"import": "./lib/esm/sdk/design/beta.js"
|
|
17
17
|
},
|
|
18
18
|
"./test": {
|
|
19
|
-
"types": "./test/
|
|
20
|
-
"require": "./lib/cjs/sdk/design/test/
|
|
21
|
-
"import": "./lib/esm/sdk/design/test/
|
|
19
|
+
"types": "./test/beta.d.ts",
|
|
20
|
+
"require": "./lib/cjs/sdk/design/test/beta.js",
|
|
21
|
+
"import": "./lib/esm/sdk/design/test/beta.js"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
"typings": "./
|
|
24
|
+
"typings": "./beta.d.ts"
|
|
25
25
|
}
|
|
File without changes
|