@canva/design 2.7.0 → 2.7.1-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
@@ -2919,39 +2924,53 @@ export declare type DragStartEvent<E extends Element> = Pick<
2919
2924
  };
2920
2925
 
2921
2926
  /**
2922
- * @public
2923
- * Reads and edits content of the specified type from the user's design.
2924
- * @param options - Options for configuring how a design is read.
2925
- * @param callback - A callback for operating on the read content.
2926
- *
2927
- * @example Read richtext content
2928
- * ```typescript
2929
- * import { editContent } from "@canva/design";
2930
- *
2931
- * await editContent(
2932
- * { contentType: 'richtext', target: 'current_page' },
2933
- * async (session) => {
2934
- * // Do something with the richtext content, e.g. `session.contents`
2935
- * }
2936
- * );
2937
- * ```
2927
+ * @beta
2928
+ * Reads and edits richtext content from the user's design.
2929
+ * @param options - Options for configuring how a design is read. Must specify `contentType: 'richtext'`.
2930
+ * @param callback - A callback that receives a `RichtextContentSession` for editing.
2931
+ * @returns A promise that resolves when editing is complete.
2938
2932
  */
2939
- export declare const editContent: (
2940
- options: EditContentOptions,
2941
- callback: EditContentCallback,
2942
- ) => Promise<void>;
2933
+ export declare function editContent(
2934
+ options: EditContentOptions & {
2935
+ contentType: "richtext";
2936
+ },
2937
+ callback: (session: RichtextContentSession) => Promise<void> | void,
2938
+ ): Promise<void>;
2939
+
2940
+ /**
2941
+ * @beta
2942
+ * Reads and edits fill content from the user's design.
2943
+ * @param options - Options for configuring how a design is read. Must specify `contentType: 'fill'`.
2944
+ * @param callback - A callback that receives a `FillContentSession` for editing.
2945
+ * @returns A promise that resolves when editing is complete.
2946
+ */
2947
+ export declare function editContent(
2948
+ options: EditContentOptions & {
2949
+ contentType: "fill";
2950
+ },
2951
+ callback: (session: FillContentSession) => Promise<void> | void,
2952
+ ): Promise<void>;
2953
+
2954
+ /**
2955
+ * @beta
2956
+ * A callback for reading and updating the requested design content.
2957
+ * @param session - Session for reading and updating content in the design.
2958
+ */
2959
+ export declare type EditContentCallback = (
2960
+ session: RichtextContentSession | FillContentSession,
2961
+ ) => Promise<void> | void;
2943
2962
 
2944
2963
  /**
2945
2964
  * @public
2946
2965
  * A callback for reading and updating the requested design content.
2947
2966
  * @param session - The result of reading the content in the design.
2948
2967
  */
2949
- export declare type EditContentCallback = (
2968
+ declare type EditContentCallback_2 = (
2950
2969
  session: RichtextContentSession,
2951
2970
  ) => Promise<void> | void;
2952
2971
 
2953
2972
  /**
2954
- * @public
2973
+ * @beta
2955
2974
  * Options for configuring how the design content is read.
2956
2975
  */
2957
2976
  export declare type EditContentOptions = {
@@ -2961,6 +2980,17 @@ export declare type EditContentOptions = {
2961
2980
  contentType: ContentType;
2962
2981
  } & ContextOptions;
2963
2982
 
2983
+ /**
2984
+ * @public
2985
+ * Options for configuring how the design content is read.
2986
+ */
2987
+ declare type EditContentOptions_2 = {
2988
+ /**
2989
+ * The type of content to edit from the user's design
2990
+ */
2991
+ contentType: ContentType_2;
2992
+ } & ContextOptions;
2993
+
2964
2994
  /**
2965
2995
  * @public
2966
2996
  * Elements targeting a cursor are a subset of the base Element
@@ -3191,6 +3221,67 @@ export declare type Fill = {
3191
3221
  asset?: ImageFill | VideoFill;
3192
3222
  };
3193
3223
 
3224
+ /**
3225
+ * @beta
3226
+ * Object for interacting with fill content (images/videos).
3227
+ */
3228
+ export declare type FillContent =
3229
+ | {
3230
+ type: "image";
3231
+ /**
3232
+ * A unique identifier that points to an image asset in Canva's backend.
3233
+ */
3234
+ ref: ImageRef;
3235
+ /**
3236
+ * A description of the image content.
3237
+ *
3238
+ * @remarks
3239
+ * Use `undefined` for content with no description.
3240
+ */
3241
+ altText?: AltText;
3242
+ /**
3243
+ * Indicates whether the object containing this fill has been deleted.
3244
+ */
3245
+ deleted: boolean;
3246
+ }
3247
+ | {
3248
+ type: "video";
3249
+ /**
3250
+ * A unique identifier that points to an video asset in Canva's backend.
3251
+ */
3252
+ ref: VideoRef;
3253
+ /**
3254
+ * A description of the video content.
3255
+ *
3256
+ * @remarks
3257
+ * Use `undefined` for content with no description.
3258
+ */
3259
+ altText?: AltText;
3260
+ /**
3261
+ * Indicates whether the object containing this fill has been deleted.
3262
+ */
3263
+ deleted: boolean;
3264
+ };
3265
+
3266
+ /**
3267
+ * @beta
3268
+ * Session for reading and updating fill content in a user's design.
3269
+ */
3270
+ export declare interface FillContentSession {
3271
+ /**
3272
+ * Fill content in the design.
3273
+ */
3274
+ readonly contents: readonly FillContent[];
3275
+ /**
3276
+ * Saves any changes made during the session while keeping the transaction open.
3277
+ *
3278
+ * @remarks
3279
+ * - Any changes in the session are only reflected in the design after this method is called.
3280
+ * - Once this method is called, further changes in the session can still be made.
3281
+ */
3282
+ sync(): Promise<void>;
3283
+ }
3284
+
3194
3285
  /**
3195
3286
  * @public
3196
3287
  * A reference to a font that can be used in other parts of the SDK.
@@ -4820,6 +4911,11 @@ export declare type TextDragConfig = {
4820
4911
  * @defaultValue "none"
4821
4912
  */
4822
4913
  decoration?: "none" | "underline";
4914
+ /**
4915
+ * @beta
4916
+ * A unique identifier that points to a font asset in Canva's backend.
4917
+ */
4918
+ fontRef?: FontRef;
4823
4919
  };
4824
4920
 
4825
4921
  /**
@@ -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.0",
3
+ "version": "2.7.1-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