@canva/design 2.7.1 → 2.7.2-beta.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.
@@ -1015,11 +1015,16 @@ export declare interface ContentDraft<T> {
1015
1015
  save(): Promise<void>;
1016
1016
  }
1017
1017
 
1018
+ /**
1019
+ * @beta
1020
+ */
1021
+ export declare type ContentType = "richtext" | "fill";
1022
+
1018
1023
  /**
1019
1024
  * @public
1020
1025
  * A type of content that can be read from a user's design.
1021
1026
  */
1022
- export declare type ContentType = "richtext";
1027
+ declare type ContentType_2 = "richtext";
1023
1028
 
1024
1029
  /**
1025
1030
  * @public
@@ -2921,39 +2926,53 @@ export declare type DragStartEvent<E extends Element> = Pick<
2921
2926
  };
2922
2927
 
2923
2928
  /**
2924
- * @public
2925
- * Reads and edits content of the specified type from the user's design.
2926
- * @param options - Options for configuring how a design is read.
2927
- * @param callback - A callback for operating on the read content.
2928
- *
2929
- * @example Read richtext content
2930
- * ```typescript
2931
- * import { editContent } from "@canva/design";
2932
- *
2933
- * await editContent(
2934
- * { contentType: 'richtext', target: 'current_page' },
2935
- * async (session) => {
2936
- * // Do something with the richtext content, e.g. `session.contents`
2937
- * }
2938
- * );
2939
- * ```
2929
+ * @beta
2930
+ * Reads and edits richtext content from the user's design.
2931
+ * @param options - Options for configuring how a design is read. Must specify `contentType: 'richtext'`.
2932
+ * @param callback - A callback that receives a `RichtextContentSession` for editing.
2933
+ * @returns A promise that resolves when editing is complete.
2940
2934
  */
2941
- export declare const editContent: (
2942
- options: EditContentOptions,
2943
- callback: EditContentCallback,
2944
- ) => Promise<void>;
2935
+ export declare function editContent(
2936
+ options: EditContentOptions & {
2937
+ contentType: "richtext";
2938
+ },
2939
+ callback: (session: RichtextContentSession) => Promise<void> | void,
2940
+ ): Promise<void>;
2941
+
2942
+ /**
2943
+ * @beta
2944
+ * Reads and edits fill content from the user's design.
2945
+ * @param options - Options for configuring how a design is read. Must specify `contentType: 'fill'`.
2946
+ * @param callback - A callback that receives a `FillContentSession` for editing.
2947
+ * @returns A promise that resolves when editing is complete.
2948
+ */
2949
+ export declare function editContent(
2950
+ options: EditContentOptions & {
2951
+ contentType: "fill";
2952
+ },
2953
+ callback: (session: FillContentSession) => Promise<void> | void,
2954
+ ): Promise<void>;
2955
+
2956
+ /**
2957
+ * @beta
2958
+ * A callback for reading and updating the requested design content.
2959
+ * @param session - Session for reading and updating content in the design.
2960
+ */
2961
+ export declare type EditContentCallback = (
2962
+ session: RichtextContentSession | FillContentSession,
2963
+ ) => Promise<void> | void;
2945
2964
 
2946
2965
  /**
2947
2966
  * @public
2948
2967
  * A callback for reading and updating the requested design content.
2949
2968
  * @param session - The result of reading the content in the design.
2950
2969
  */
2951
- export declare type EditContentCallback = (
2970
+ declare type EditContentCallback_2 = (
2952
2971
  session: RichtextContentSession,
2953
2972
  ) => Promise<void> | void;
2954
2973
 
2955
2974
  /**
2956
- * @public
2975
+ * @beta
2957
2976
  * Options for configuring how the design content is read.
2958
2977
  */
2959
2978
  export declare type EditContentOptions = {
@@ -2963,6 +2982,17 @@ export declare type EditContentOptions = {
2963
2982
  contentType: ContentType;
2964
2983
  } & ContextOptions;
2965
2984
 
2985
+ /**
2986
+ * @public
2987
+ * Options for configuring how the design content is read.
2988
+ */
2989
+ declare type EditContentOptions_2 = {
2990
+ /**
2991
+ * The type of content to edit from the user's design
2992
+ */
2993
+ contentType: ContentType_2;
2994
+ } & ContextOptions;
2995
+
2966
2996
  /**
2967
2997
  * @public
2968
2998
  * Elements targeting a cursor are a subset of the base Element
@@ -3193,6 +3223,67 @@ export declare type Fill = {
3193
3223
  asset?: ImageFill | VideoFill;
3194
3224
  };
3195
3225
 
3226
+ /**
3227
+ * @beta
3228
+ * Object for interacting with fill content (images/videos).
3229
+ */
3230
+ export declare type FillContent =
3231
+ | {
3232
+ type: "image";
3233
+ /**
3234
+ * A unique identifier that points to an image asset in Canva's backend.
3235
+ */
3236
+ ref: ImageRef;
3237
+ /**
3238
+ * A description of the image content.
3239
+ *
3240
+ * @remarks
3241
+ * Use `undefined` for content with no description.
3242
+ */
3243
+ altText?: AltText;
3244
+ /**
3245
+ * Indicates whether the object containing this fill has been deleted.
3246
+ */
3247
+ deleted: boolean;
3248
+ }
3249
+ | {
3250
+ type: "video";
3251
+ /**
3252
+ * A unique identifier that points to an video asset in Canva's backend.
3253
+ */
3254
+ ref: VideoRef;
3255
+ /**
3256
+ * A description of the video content.
3257
+ *
3258
+ * @remarks
3259
+ * Use `undefined` for content with no description.
3260
+ */
3261
+ altText?: AltText;
3262
+ /**
3263
+ * Indicates whether the object containing this fill has been deleted.
3264
+ */
3265
+ deleted: boolean;
3266
+ };
3267
+
3268
+ /**
3269
+ * @beta
3270
+ * Session for reading and updating fill content in a user's design.
3271
+ */
3272
+ export declare interface FillContentSession {
3273
+ /**
3274
+ * Fill content in the design.
3275
+ */
3276
+ readonly contents: readonly FillContent[];
3277
+ /**
3278
+ * Saves any changes made during the session while keeping the transaction open.
3279
+ *
3280
+ * @remarks
3281
+ * - Any changes in the session are only reflected in the design after this method is called.
3282
+ * - Once this method is called, further changes in the session can still be made.
3283
+ */
3284
+ sync(): Promise<void>;
3285
+ }
3286
+
3196
3287
  /**
3197
3288
  * @public
3198
3289
  * A reference to a font that can be used in other parts of the SDK.
@@ -4823,6 +4914,11 @@ export declare type TextDragConfig = {
4823
4914
  * @defaultValue "none"
4824
4915
  */
4825
4916
  decoration?: "none" | "underline";
4917
+ /**
4918
+ * @beta
4919
+ * A unique identifier that points to a font asset in Canva's backend.
4920
+ */
4921
+ fontRef?: FontRef;
4826
4922
  };
4827
4923
 
4828
4924
  /**
@@ -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, "editContent", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return editContent;
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,8 @@ function _export_star(from, to) {
17
23
  return from;
18
24
  }
19
25
  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.7.0', 'ga');
26
+ const { canva_sdk } = window;
27
+ function editContent(options, callback) {
28
+ return canva_sdk.design.v2.designInteraction.editContent(options, (session)=>callback(session));
29
+ }
30
+ (_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.7.0', 'beta');
@@ -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,7 @@
1
1
  var _window___canva___sdkRegistration, _window___canva__;
2
+ const { canva_sdk } = window;
3
+ export function editContent(options, callback) {
4
+ return canva_sdk.design.v2.designInteraction.editContent(options, (session)=>callback(session));
5
+ }
2
6
  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.7.0', 'ga');
7
+ (_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.7.0', 'beta');
@@ -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.7.1",
3
+ "version": "2.7.2-beta.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": "^2.0.0"
9
9
  },
10
- "main": "./lib/cjs/sdk/design/index.js",
11
- "module": "./lib/esm/sdk/design/index.js",
10
+ "main": "./lib/cjs/sdk/design/beta.js",
11
+ "module": "./lib/esm/sdk/design/beta.js",
12
12
  "exports": {
13
13
  ".": {
14
- "types": "./index.d.ts",
15
- "require": "./lib/cjs/sdk/design/index.js",
16
- "import": "./lib/esm/sdk/design/index.js"
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/index.d.ts",
20
- "require": "./lib/cjs/sdk/design/test/index.js",
21
- "import": "./lib/esm/sdk/design/test/index.js"
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": "./index.d.ts"
24
+ "typings": "./beta.d.ts"
25
25
  }
File without changes