Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 | 5x 5x 5x 5x 75x 75x 75x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 1x 75x 1x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 2x 2x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 6x 6x 6x 75x 2x 75x 2x 2x 75x 2x 2x 75x 1x 1x 75x 1x 1x 1x 75x 1x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 75x 75x 75x 75x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 75x 75x 1x 1x 1x 1x 75x 1x 1x 1x 1x 75x 1x 1x 1x 1x 75x 1x 1x 1x 1x 75x 1x 1x 1x 1x 75x 1x 1x 1x 1x 75x 75x 75x 75x 75x 75x 75x 75x 2x 2x 2x 2x 2x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x 75x 1x 1x | import { BarcodeType } from '../types/BarcodeTypes'; import { ColorUsage } from '../types/ColorStyleTypes'; import type { EditorAPI, EditorResponse, Id } from '../types/CommonTypes'; import { AnchorTarget, AutoGrowDeltaUpdate, AutoGrowDirection, BlendMode, CropType, FitMode, FitModePosition, FrameAnchorProperties, FrameAnchorType, FrameConfiguration, FrameLayoutType, FrameType, FrameTypeEnum, ImageFrameConnectorSource, ImageFrameSource, ImageFrameUrlSource, ImageSourceTypeEnum, UpdateZIndexMethod, VerticalAlign, } from '../types/FrameTypes'; import { ShapeType } from '../types/ShapeTypes'; import { getEditorResponseData } from '../utils/EditorResponseData'; import { ShapeController } from './ShapeController'; /** * The FrameController is responsible for all communication regarding Frames. * Methods inside this controller can be called by `window.SDK.frame.{method-name}` */ export class FrameController { /** * @ignore */ #editorAPI: EditorAPI; /** * @ignore */ constructor(editorAPI: EditorAPI) { this.#editorAPI = editorAPI; this.shapeController = new ShapeController(this.#editorAPI); } /** * This variable helps to redirect shapes related methods to newly introduced ShapeController * to avoid any breaking changes */ private shapeController: ShapeController; /** * This method returns the list of frames * @returns list of all frames */ getAll = async () => { const res = await this.#editorAPI; return res.getFrames().then((result) => getEditorResponseData<FrameType[]>(result)); }; /** * This method returns the list of selected frames * @returns list of all selected frames */ getSelected = async () => { const res = await this.#editorAPI; return res.getSelectedFrames().then((result) => getEditorResponseData<FrameType[]>(result)); }; /** * This method returns the list of frames by id * @param id the id of a specific page * @returns list of all frames by id */ getAllByPageId = async (id: Id) => { const res = await this.#editorAPI; return res.getFramesByPageId(id).then((result) => getEditorResponseData<FrameType[]>(result)); }; /** * This method returns a frame by its name * @param name the name of a specific frame * @returns frame properties */ getByName = async (name: string) => { const res = await this.#editorAPI; return res.getFrameByName(name).then((result) => getEditorResponseData<FrameType>(result)); }; /** * This method returns a frame by its id * @param id the id of a specific frame * @returns frame properties */ getById = async (id: Id) => { const res = await this.#editorAPI; return res.getFrameById(id).then((result) => getEditorResponseData<FrameType>(result)); }; /** * This method returns all frame properties on current layout * @returns all frame properties on current layout */ getPropertiesOnSelectedLayout = async () => { const res = await this.#editorAPI; return res .getFramePropertiesOnSelectedLayout() .then((result) => getEditorResponseData<FrameLayoutType[]>(result)); }; /** * This method returns frame layout properties for a given frame and layout * @param id the id of a specific frame * @param layoutId the id of a specific layout * @returns frame layout properties */ getLayoutProperties = async (id: Id, layoutId?: Id) => { const res = await this.#editorAPI; return res .getFramePropertiesByFrameId(id, layoutId) .then((result) => getEditorResponseData<FrameLayoutType>(result)); }; /** * This method returns a list of frame properties for a given layout * @param id the id of a specific layout * @returns list of frame layout properties */ getAllLayoutProperties = async (id: Id) => { const res = await this.#editorAPI; return res.getFramesProperties(id).then((result) => getEditorResponseData<FrameLayoutType[]>(result)); }; /** * This method will reset the frame's transformation properties (x, y, width, height, rotation, anchors) * to the frame's to be inherited from the parent layout * @param id the id of a specific frame * @returns */ resetTransformation = async (id: Id) => { const res = await this.#editorAPI; return res.resetFrameTransformation(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the frame's transformation properties (x, y, width, height, rotation, anchors) * to the frame's to be inherited from the parent layout * @param id the id of a specific frame * @returns * @deprecated Use 'resetTransformation' instead */ resetSize = async (id: Id) => { const res = await this.#editorAPI; return res.resetFrameTransformation(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will select a specific frame * @param id the id of a specific frame * @returns */ select = async (id: Id) => { const res = await this.#editorAPI; return res.selectFrames([id]).then((result) => getEditorResponseData<null>(result)); }; /** * This method will select multipleFrames * @param ids An array of all ids you want to select * @returns */ selectMultiple = async (ids: Id[]) => { const res = await this.#editorAPI; return res.selectFrames(ids).then((result) => getEditorResponseData<null>(result)); }; /** * This method will deselect all frames * @returns */ deselectAll = async () => { const res = await this.#editorAPI; return res.deselectFrames().then((result) => getEditorResponseData<null>(result)); }; /** * This method changes the order of frames in the z-index list. * @param order the index in the list to move to * @param ids An array of all IDs you want to move to the given index * @returns */ reorderFrames = async (order: number, ids: Id[]) => { const res = await this.#editorAPI; return res.reorderFrames(order, ids).then((result) => getEditorResponseData<null>(result)); }; /** * This method will update the z-index of a frame. * @param id the id of the frame you want to change the z-index of * @param method the z-index update method to perform * @returns */ setZIndex = async (id: Id, method: UpdateZIndexMethod) => { const res = await this.#editorAPI; return res.setFrameZIndex(id, method).then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the height of a specific frame * @param id the id of a specific frame * @param height the string value that will be calculated (f.e. 1+1 will result in 2) The notation is in pixels * @returns */ setHeight = async (id: Id, height: string) => { const res = await this.#editorAPI; return res.setFrameHeight(id, height).then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the rotation angle of a specific frame * @param id the id of a specific frame * @param rotation the string value that will be calculated (f.e. 1+1 will result in 2) The notation is in pixels * @returns */ setRotation = async (id: Id, rotation: string) => { const res = await this.#editorAPI; return res.setFrameRotation(id, rotation).then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the width of a specific frame * @param id the id of a specific frame * @param width the string value that will be calculated (f.e. 1+1 will result in 2) The notation is in pixels * @returns */ setWidth = async (id: Id, width: string) => { const res = await this.#editorAPI; return res.setFrameWidth(id, width).then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the x value of a specific frame * @param id the id of a specific frame * @param XValue the string value that will be calculated (f.e. 1+1 will result in 2) The notation is in pixels * @returns */ setX = async (id: Id, XValue: string) => { const res = await this.#editorAPI; return res.setFrameX(id, XValue).then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the y value of a specific frame * @param id the id of a specific frame * @param YValue the string value that will be calculated (f.e. 1+1 will result in 2) The notation is in pixels * @returns */ setY = async (id: Id, YValue: string) => { const res = await this.#editorAPI; return res.setFrameY(id, YValue).then((result) => getEditorResponseData<null>(result)); }; /** * This method will update the name of a specific frame * @param id the id of a specific frame * @param name the new name that the frame should receive * @returns */ rename = async (id: Id, name: string) => { const res = await this.#editorAPI; return res.renameFrame(id, name).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset properties of a specific frame to their original values * @param id the id of the frame that needs to get reset * @returns */ reset = async (id: Id) => { const res = await this.#editorAPI; return res.resetFrame(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the frame's transformation properties (x, y, width, height, rotation, anchors) * to the frame's to be inherited from the parent layout * @param id the id of a specific frame * @returns * @deprecated Use 'resetTransformation' instead */ resetX = async (id: Id) => { const res = await this.#editorAPI; return res.resetFrameTransformation(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the frame's transformation properties (x, y, width, height, rotation, anchors) * to the frame's to be inherited from the parent layout * @param id the id of a specific frame * @returns * @deprecated Use 'resetTransformation' instead */ resetY = async (id: Id) => { const res = await this.#editorAPI; return res.resetFrameTransformation(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the frame's transformation properties (x, y, width, height, rotation, anchors) * to the frame's to be inherited from the parent layout * @param id the id of a specific frame * @returns * @deprecated Use 'resetTransformation' instead */ resetRotation = async (id: Id) => { const res = await this.#editorAPI; return res.resetFrameTransformation(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the frame's transformation properties (x, y, width, height, rotation, anchors) * to the frame's to be inherited from the parent layout * @param id the id of a specific frame * @returns * @deprecated Use 'resetTransformation' instead */ resetWidth = async (id: Id) => { const res = await this.#editorAPI; return res.resetFrameTransformation(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the frame's transformation properties (x, y, width, height, rotation, anchors) * to the frame's to be inherited from the parent layout * @param id the id of a specific frame * @returns * @deprecated Use 'resetTransformation' instead */ resetHeight = async (id: Id) => { const res = await this.#editorAPI; return res.resetFrameTransformation(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the fitMode, position and crop properties of a specific frame to its original value * @param id the id of the frame that needs to get reset * @returns */ resetImageFrameFitMode = async (id: Id) => { const res = await this.#editorAPI; return res.resetImageFrameFitMode(id).then((result) => getEditorResponseData<null>(result)); }; /** * @deprecated Use `setIsVisible` instead. * * This method will set the visibility property of a specified frame. If set to false the frame will be invisible and vice versa. * @param id the id of the frame that needs to get updated * @param value True means the frame gets visible, false means the frame gets invisible * @returns */ setVisibility = async (id: Id, value: boolean) => { const res = await this.#editorAPI; return res.setFrameIsVisible(id, value).then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the isVisible property of a specified frame. If set to false the frame will be invisible and vice versa. * @param id the id of the frame that needs to get updated * @param value True means the frame gets visible, false means the frame gets invisible * @returns */ setIsVisible = async (id: Id, value: boolean) => { const res = await this.#editorAPI; return res.setFrameIsVisible(id, value).then((result) => getEditorResponseData<null>(result)); }; /** * This method will remove a specific frame using the Id. * @param id the id of the frame that needs to be deleted * @returns */ remove = async (id: Id) => { const res = await this.#editorAPI; return res.removeFrames([id]).then((result) => getEditorResponseData<null>(result)); }; /** * This method will remove frames with the given ids. * @param ids an array of ids of the frames to be removed. * @returns */ removeFrames = async (ids: Id[]) => { const res = await this.#editorAPI; return res.removeFrames(ids).then((result) => getEditorResponseData<null>(result)); }; /** * This method will create a new frame of 'type' to the template positioned on the requested * coordinates. * @param type the type of frame to create * @param x X coordinate of the new frame within the template * @param y Y coordinate of the new frame within the template * @param width Width of the new frame within the template * @param height Height of the new frame within the template * @returns the newly created frame's id */ create = async (type: FrameTypeEnum, x: number, y: number, width: number, height: number) => { const res = await this.#editorAPI; return res.addFrame(type, x, y, width, height).then((result) => getEditorResponseData<Id>(result)); }; /** * This method will create a new frame of 'type' type to the template positioned on the requested * coordinates. * @param type the type of frame to create * @param x X coordinate of the new frame within the template * @param y Y coordinate of the new frame within the template * @param width Width of the new frame within the template * @param height Height of the new frame within the template * @returns the newly created shape frame's id */ createShapeFrame = async (type: ShapeType, x: number, y: number, width: number, height: number) => { const res = await this.#editorAPI; return res.addFrame(type, x, y, width, height).then((result) => getEditorResponseData<Id>(result)); }; /** * @experimental This method will create a new barcode frame of 'type' type to the layout positioned on the requested * coordinates. Any coordinate that is not specified will default to 'center'. * @param type the type of barcode to create * @param position optional position object where you can specify the x, y of the barcode frame * @returns */ createBarcodeFrame = async (type: BarcodeType, position?: { x?: number; y?: number }) => { const res = await this.#editorAPI; return res.addBarcodeFrame(type, position?.x, position?.y).then((result) => getEditorResponseData<Id>(result)); }; /** * This method will duplicate a list of frames * @param ids An array of all ids you want to duplicate * @returns */ duplicateFrames = async (ids: Id[]) => { const res = await this.#editorAPI; return res.duplicateFrames(ids).then((result) => getEditorResponseData<Id>(result)); }; /** * This method sets or removes the image source to the ImageFrame * @param imageFrameId the id of the imageFrame where an image needs to be assigned to * @param newImageSource A new image source * @returns */ private updateImageSource = async (imageFrameId: Id, src: ImageFrameSource | null) => { const res = await this.#editorAPI; const srcJson = src !== null ? JSON.stringify(src) : null; return res.setImageSource(imageFrameId, srcJson).then((result) => getEditorResponseData<null>(result)); }; /** * This method removes the image source from the ImageFrame * @param imageFrameId the id of the imageFrame where an image needs to be removed from */ removeImageSource = async (imageFrameId: string) => { return this.updateImageSource(imageFrameId, null); }; /** * This method will assign an image from a mediaConnector to the correct ImageFrame * @param id Unique Id of the media connector * @param imageFrameId the id of the imageFrame where an image needs to be assigned to * @param assetId Unique id of the asset that you want to assign to the imageFrame * @returns */ setImageFromConnector = async (imageFrameId: Id, connectorId: Id, assetId: Id) => { const src: ImageFrameConnectorSource = { id: connectorId, assetId, type: ImageSourceTypeEnum.connector, }; return this.updateImageSource(imageFrameId, src); }; /** * This method will assign an image from url to the correct ImageFrame * Make sure the url can be accessed by the editor. * @param imageFrameId the id of the imageFrame where an image needs to be assigned to * @param url A valid image uri * @returns */ setImageFromUrl = async (imageFrameId: Id, url: string) => { const source: ImageFrameUrlSource = { url: url, type: ImageSourceTypeEnum.url }; return this.updateImageSource(imageFrameId, source); }; /** * This method will set the fitMode property of a specified image frame. * @param imageFrameId the id of the imageFrame that needs to get updated. * @param fitMode the new fitMode that you want to set to the imageFrame. * @returns */ setImageFrameFitMode = async (imageFrameId: Id, fitMode: FitMode) => { const res = await this.#editorAPI; return res.setImageFrameFitMode(imageFrameId, fitMode).then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the fit mode position property of a specified image frame. * @param imageFrameId the id of the imageFrame that needs to get updated. * @param position the new position that you want to set to the imageFrame. * @returns */ setImageFrameFitModePosition = async (imageFrameId: Id, position: FitModePosition) => { const res = await this.#editorAPI; return res .setImageFrameFitModePosition(imageFrameId, position) .then((result) => getEditorResponseData<null>(result)); }; /** * @deprecated the constrain proportions setter is not supported anymore. * * This method will set the constrainProportions property of a specified frame. If constrainProportionsReadOnly is * true, the frame's constrainProportions property cannot be changed and this method will return an error. * * @param _id the id of the frame that needs to get updated. * @param _constrainProportions The new constraint that you want to set to the frame. * @returns */ // eslint-disable-next-line @typescript-eslint/no-unused-vars setFrameConstrainProportions = async (_id: Id, _constrainProportions: boolean) => { console.error('setFrameConstrainProportions is not supported anymore'); const res: EditorResponse<null> = { success: false, status: 0, error: 'setFrameConstrainProportions is not supported anymore', parsedData: null, }; return getEditorResponseData<null>(res); }; /** * This method will set the vertical alignment property of a specified frame. * @param id the id of the frame that needs to get updated * @param verticalAlign the new vertical alignment to be set to the frame. * @returns */ setVerticalAlign = async (id: Id, verticalAlign: VerticalAlign) => { const res = await this.#editorAPI; return res.setVerticalAlignment(id, verticalAlign).then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the min copyFitting property of a specified frame. * @param id the id of the frame that needs to get updated * @param value the new min copyFitting value to be set to the frame. * @returns */ setMinCopyfitting = async (id: Id, value: string) => { const res = await this.#editorAPI; return res.setMinCopyfitting(id, value).then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the max copyFitting property of a specified frame. * @param id the id of the frame that needs to get updated * @param value the new max copyFitting value to be set to the frame. * @returns */ setMaxCopyfitting = async (id: Id, value: string) => { const res = await this.#editorAPI; return res.setMaxCopyfitting(id, value).then((result) => getEditorResponseData<null>(result)); }; /** * This method will enable copyFitting on a specified frame. * @param id the id of the frame that needs to get updated * @param value the new value to be set to the frame. * @returns */ setEnableCopyfitting = async (id: Id, value: boolean) => { const res = await this.#editorAPI; return res.setEnableCopyfitting(id, value).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the frame minCopyfitting to the frame's original value * @param id the id of a specific frame * @returns */ resetMinCopyfitting = async (id: Id) => { const res = await this.#editorAPI; return res.resetMinCopyfitting(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the frame maxCopyfitting to the frame's original value * @param id the id of a specific frame * @returns */ resetMaxCopyfitting = async (id: Id) => { const res = await this.#editorAPI; return res.resetMaxCopyfitting(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the frame enableCopyfitting to the frame's original value * @param id the id of a specific frame * @returns */ resetEnableCopyfitting = async (id: Id) => { const res = await this.#editorAPI; return res.resetEnableCopyfitting(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the visibility of the shape fill. * @param shapeFrameId the id of the shapeFrame that needs to get updated. * @param enableFill Whether the shape fill is visible. * @returns */ setShapeFrameEnableFill = async (shapeFrameId: Id, enableFill: boolean) => { return this.shapeController.setEnableFill(shapeFrameId, enableFill); }; /** * This method will set the shape fill color of a specified shape frame. * @param shapeFrameId the id of the shapeFrame that needs to get updated. * @param fillColor the new shape fill color that you want to set to the shapeFrame. * @returns */ setShapeFrameFillColor = async (shapeFrameId: Id, fillColor: ColorUsage) => { return this.shapeController.setFillColor(shapeFrameId, fillColor); }; /** * This method will set the visibility of the shape stroke. * @param shapeFrameId the id of the shapeFrame that needs to get updated. * @param enableStroke Whether the shape stroke is visible. * @returns */ setShapeFrameEnableStroke = async (shapeFrameId: Id, enableStroke: boolean) => { return this.shapeController.setEnableStroke(shapeFrameId, enableStroke); }; /** * This method will set the shape stroke color of a specified shape frame. * @param shapeFrameId the id of the shapeFrame that needs to get updated. * @param strokeColor the new shape stroke color that you want to set to the shapeFrame. * @returns */ setShapeFrameStrokeColor = async (shapeFrameId: Id, strokeColor: ColorUsage) => { return this.shapeController.setStrokeColor(shapeFrameId, strokeColor); }; /** * This method will set the shape stroke weight of a specified shape frame. * @param shapeFrameId the id of the shapeFrame that needs to get updated. * @param strokeWeight the new shape stroke weight that you want to set to the shapeFrame. * @returns */ setShapeFrameStrokeWeight = async (shapeFrameId: Id, strokeWeight: number) => { return this.shapeController.setStrokeWeight(shapeFrameId, strokeWeight); }; /** * This method will set the blend mode of a specified frame * @param id the id of a specific frame * @param blendMode the blend mode * @returns */ setBlendMode = async (id: Id, blendMode: BlendMode) => { const res = await this.#editorAPI; return res.setFrameBlendMode(id, blendMode).then((result) => getEditorResponseData<null>(result)); }; /** * This method will make the specified image frame go into cropping mode. * @param id the id of a specific image frame * @param type the type of cropping mode to enter. Defaults to frameCrop. * @returns */ enterCropMode = async (id: Id, type: CropType = CropType.frameCrop) => { const res = await this.#editorAPI; return res.enterCropMode(id, type).then((result) => getEditorResponseData<null>(result)); }; /** * This method will exit cropping mode while saving the applied crop. * @returns */ applyCropMode = async () => { const res = await this.#editorAPI; return res.applyCropMode().then((result) => getEditorResponseData<null>(result)); }; /** * This method will exit cropping mode without saving the applied crop. * @returns */ exitCropMode = async () => { const res = await this.#editorAPI; return res.cancelCropMode().then((result) => getEditorResponseData<null>(result)); }; /** * This method will make the specified image frame go into subject mode. * @param id the id of a specific image frame * @returns */ enterSubjectMode = async (id: Id) => { const res = await this.#editorAPI; return res.enterSubjectMode(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will exit subject mode while saving the applied subject area. * @returns */ applySubjectMode = async () => { const res = await this.#editorAPI; return res.applySubjectMode().then((result) => getEditorResponseData<null>(result)); }; /** * This method will exit subject mode without saving the applied subject area. * @returns */ exitSubjectMode = async () => { const res = await this.#editorAPI; return res.cancelSubjectMode().then((result) => getEditorResponseData<null>(result)); }; /** * @deprecated This method no longer has any effect. Use 'setImageFrameFitMode' or 'resetImageFrameFitMode' instead */ // eslint-disable-next-line @typescript-eslint/no-unused-vars resetCropMode = async (_id: Id) => { console.error('resetCropMode is not supported anymore'); const res: EditorResponse<null> = { success: false, status: 0, error: 'resetCropMode is not supported anymore', parsedData: null, }; return getEditorResponseData<null>(res); }; /** * This method will enable auto grow on a specified frame. * @param id the id of the frame that needs to get updated * @param value the new value to be set to the frame. * @returns */ setEnableAutoGrow = async (id: Id, value: boolean) => { const update: AutoGrowDeltaUpdate = { enabled: { value: value } }; const res = await this.#editorAPI; return res .updateAutoGrowSettings(id, JSON.stringify(update)) .then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the minWidth for auto-grow of a specified frame. Set to null to remove the value. * @param id the id of the frame that needs to get updated * @param value the new minWidth value to be set * @returns */ setAutoGrowMinWidth = async (id: Id, value: string | null) => { const update: AutoGrowDeltaUpdate = { minWidth: { value } }; const res = await this.#editorAPI; return res .updateAutoGrowSettings(id, JSON.stringify(update)) .then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the maxWidth for auto-grow of a specified frame. Set to null to remove the value. * @param id the id of the frame that needs to get updated * @param value the new maxWidth value to be set * @returns */ setAutoGrowMaxWidth = async (id: Id, value: string | null) => { const update: AutoGrowDeltaUpdate = { maxWidth: { value } }; const res = await this.#editorAPI; return res .updateAutoGrowSettings(id, JSON.stringify(update)) .then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the minHeight for auto-grow of a specified frame. Set to null to remove the value. * @param id the id of the frame that needs to get updated * @param value the new minHeight value to be set * @returns */ setAutoGrowMinHeight = async (id: Id, value: string | null) => { const update: AutoGrowDeltaUpdate = { minHeight: { value } }; const res = await this.#editorAPI; return res .updateAutoGrowSettings(id, JSON.stringify(update)) .then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the maxHeight for auto-grow of a specified frame. Set to null to remove the value. * @param id the id of the frame that needs to get updated * @param value the new maxHeight value to be set * @returns */ setAutoGrowMaxHeight = async (id: Id, value: string | null) => { const update: AutoGrowDeltaUpdate = { maxHeight: { value } }; const res = await this.#editorAPI; return res .updateAutoGrowSettings(id, JSON.stringify(update)) .then((result) => getEditorResponseData<null>(result)); }; /** * This method will set the auto grow directions for auto-grow of a specified frame. * @param id the id of the frame that needs to get updated * @param value the new directions value to be set * @returns */ setAutoGrowDirections = async (id: Id, value: Array<AutoGrowDirection>) => { const update: AutoGrowDeltaUpdate = { directions: { value } }; const res = await this.#editorAPI; return res .updateAutoGrowSettings(id, JSON.stringify(update)) .then((result) => getEditorResponseData<null>(result)); }; /** * @deprecated This method no longer has any effect. Use `resetTransformation` instead */ // eslint-disable-next-line @typescript-eslint/no-unused-vars resetAutoGrowSettingsEnabled = async (_id: Id) => { console.error('resetAutoGrowSettingsEnabled is not supported anymore'); const res: EditorResponse<null> = { success: false, status: 0, error: 'resetAutoGrowSettingsEnabled is not supported anymore', parsedData: null, }; return getEditorResponseData<null>(res); }; /** * @deprecated This method no longer has any effect. Use `resetTransformation` instead */ // eslint-disable-next-line @typescript-eslint/no-unused-vars resetAutoGrowMinWidth = async (_id: Id) => { console.error('resetAutoGrowMinWidth is not supported anymore'); const res: EditorResponse<null> = { success: false, status: 0, error: 'resetAutoGrowMinWidth is not supported anymore', parsedData: null, }; return getEditorResponseData<null>(res); }; /** * @deprecated This method no longer has any effect. Use `resetTransformation` instead */ // eslint-disable-next-line @typescript-eslint/no-unused-vars resetAutoGrowMaxWidth = async (_id: Id) => { console.error('resetAutoGrowMaxWidth is not supported anymore'); const res: EditorResponse<null> = { success: false, status: 0, error: 'resetAutoGrowMaxWidth is not supported anymore', parsedData: null, }; return getEditorResponseData<null>(res); }; /** * @deprecated This method no longer has any effect. Use `resetTransformation` instead */ // eslint-disable-next-line @typescript-eslint/no-unused-vars resetAutoGrowMinHeight = async (_id: Id) => { console.error('resetAutoGrowMinHeight is not supported anymore'); const res: EditorResponse<null> = { success: false, status: 0, error: 'resetAutoGrowMinHeight is not supported anymore', parsedData: null, }; return getEditorResponseData<null>(res); }; /** * @deprecated This method no longer has any effect. Use `resetTransformation` instead */ // eslint-disable-next-line @typescript-eslint/no-unused-vars resetAutoGrowMaxHeight = async (_id: Id) => { console.error('resetAutoGrowMaxHeight is not supported anymore'); const res: EditorResponse<null> = { success: false, status: 0, error: 'resetAutoGrowMaxHeight is not supported anymore', parsedData: null, }; return getEditorResponseData<null>(res); }; /** * @deprecated This method no longer has any effect. Use `resetTransformation` instead */ // eslint-disable-next-line @typescript-eslint/no-unused-vars resetAutoGrowDirections = async (_id: Id) => { console.error('resetAutoGrowDirections is not supported anymore'); const res: EditorResponse<null> = { success: false, status: 0, error: 'resetAutoGrowDirections is not supported anymore', parsedData: null, }; return getEditorResponseData<null>(res); }; /** * @deprecated This method no longer has any effect. Use `resetTransformation` instead */ // eslint-disable-next-line @typescript-eslint/no-unused-vars resetAutoGrow = async (_id: Id) => { console.error('resetAutoGrow is not supported anymore'); const res: EditorResponse<null> = { success: false, status: 0, error: 'resetAutoGrow is not supported anymore', parsedData: null, }; return getEditorResponseData<null>(res); }; private setAnchor = async ( id: Id, horizontal: boolean, anchorType: FrameAnchorType, anchorTarget: AnchorTarget, endAnchorTarget?: AnchorTarget | null, ) => { const properties: FrameAnchorProperties = { horizontal: horizontal, type: anchorType, target: anchorTarget, endTarget: endAnchorTarget, }; const res = await this.#editorAPI; return res .setAnchorProperties(id, JSON.stringify(properties)) .then((result) => getEditorResponseData<null>(result)); }; /** * @experimental * This method will set the vertical anchor to target frame on a specified frame. * @param id the id of the frame that needs to get a frame anchor set * @param anchorType the type of positioning to be set to the frame * @param anchorTarget the target frame to which it is anchored * @param endAnchorTarget the target (end) frame to which it can be anchored * @returns */ setVerticalAnchor = async ( id: Id, anchorType: FrameAnchorType, anchorTarget: AnchorTarget, endAnchorTarget?: AnchorTarget | null, ) => { return this.setAnchor(id, false, anchorType, anchorTarget, endAnchorTarget); }; /** * @experimental * This method will set the horizontal anchor to target frame on a specified frame. * @param id the id of the frame that needs to get a frame anchor set * @param anchorType the type of positioning to be set to the frame * @param anchorTarget the target frame to which it is anchored * @param endAnchorTarget the target (end) frame to which it can be anchored * @returns */ setHorizontalAnchor = async ( id: Id, anchorType: FrameAnchorType, anchorTarget: AnchorTarget, endAnchorTarget?: AnchorTarget | null, ) => { return this.setAnchor(id, true, anchorType, anchorTarget, endAnchorTarget); }; /** * This method will reset the frame's transformation properties (x, y, width, height, rotation, anchors) * to the frame's to be inherited from the parent layout * @param id the id of a specific frame * @returns * @deprecated Use 'resetTransformation' instead */ resetAnchoring = async (id: Id) => { const res = await this.#editorAPI; return res.resetFrameTransformation(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset the isVisible property of a specified frame. * @param id the id of the frame that needs to get updated * @returns */ resetVisibility = async (id: Id) => { const res = await this.#editorAPI; return res.setFrameIsVisible(id, null).then((result) => getEditorResponseData<null>(result)); }; /** * This method will get the frame configuration for a specified frame. * * A frame configuration is a set of rules that define what is allowed to * do with a given behavior of a frame. * * e.g. list of allowed frame targets for a specific anchor * * @param id the id of the frame to get the frame configuration for * @returns the frame's configuration */ getConfiguration = async (id: Id) => { const res = await this.#editorAPI; return res.getFrameConfiguration(id).then((result) => getEditorResponseData<FrameConfiguration>(result)); }; /** * This method will set the crop override for the current asset for the specified frame * @param id the id of the frame that holds the override to reset * @returns */ resetAssetCropOverride = async (id: Id) => { const res = await this.#editorAPI; return res.resetAssetCropOverride(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method will reset all crop overrides for the specified frame * @param id the id of the frame * @returns */ resetAllAssetCropOverrides = async (id: Id) => { const res = await this.#editorAPI; return res.resetAllAssetCropOverrides(id).then((result) => getEditorResponseData<null>(result)); }; } |