customized-fabric 1.4.9 → 1.5.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.
@@ -187,7 +187,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
187
187
  }
188
188
  },
189
189
  removeMask: async function () {
190
- this.set({ clipPath: undefined, maskUrl: "" });
190
+ this.set({ clipPath: undefined, maskUrl: undefined });
191
191
  this.remove(this.maskObject);
192
192
  this.maskObject = undefined;
193
193
  this.canvas?.renderAll();
@@ -0,0 +1,4 @@
1
+ export declare const LAYOUT_GROUP_OBJECT_ATTRIBUTES: {
2
+ name: string;
3
+ type: string;
4
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LAYOUT_GROUP_OBJECT_ATTRIBUTES = void 0;
4
+ exports.LAYOUT_GROUP_OBJECT_ATTRIBUTES = {
5
+ name: "Layout group",
6
+ type: "LAYOUT_GROUP",
7
+ };
@@ -0,0 +1,16 @@
1
+ import { fabric } from "fabric";
2
+ import { ILayoutGroupOptions } from "./interfaces";
3
+ export default class LayoutGroup {
4
+ _id: string;
5
+ name?: string;
6
+ type?: string;
7
+ locked?: boolean;
8
+ isAdditional?: boolean;
9
+ canvas?: fabric.Canvas;
10
+ group?: fabric.ActiveSelection;
11
+ private objects?;
12
+ constructor(options?: ILayoutGroupOptions);
13
+ select(): void;
14
+ delete(): void;
15
+ getObjects(): fabric.Object[] | undefined;
16
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fabric_1 = require("fabric");
4
+ const objectId_1 = require("../utils/objectId");
5
+ const constants_1 = require("./constants");
6
+ class LayoutGroup {
7
+ constructor(options) {
8
+ const { objects = [], canvas, _id } = options ?? {};
9
+ const objectId = _id ?? new objectId_1.ObjectId().toString();
10
+ objects?.map((obj) => {
11
+ obj.set({ layoutGroupId: objectId });
12
+ });
13
+ this._id = objectId;
14
+ this.type = constants_1.LAYOUT_GROUP_OBJECT_ATTRIBUTES.type;
15
+ this.name = constants_1.LAYOUT_GROUP_OBJECT_ATTRIBUTES.name;
16
+ this.objects = objects;
17
+ this.canvas = canvas;
18
+ return this;
19
+ }
20
+ select() {
21
+ const canvas = this?.canvas;
22
+ if (canvas) {
23
+ canvas.discardActiveObject();
24
+ const group = new fabric_1.fabric.ActiveSelection([], {
25
+ canvas: canvas,
26
+ isLayoutGroup: true,
27
+ });
28
+ this.objects?.map((obj) => {
29
+ group.addWithUpdate(obj);
30
+ });
31
+ canvas.setActiveObject(group);
32
+ this.group = group;
33
+ canvas.renderAll();
34
+ }
35
+ }
36
+ delete() {
37
+ this.objects?.map((obj) => {
38
+ obj.set({ layoutGroupId: undefined });
39
+ });
40
+ const group = this.group;
41
+ if (group) {
42
+ group.set({
43
+ isLayoutGroup: false,
44
+ });
45
+ }
46
+ }
47
+ getObjects() {
48
+ return this.objects;
49
+ }
50
+ }
51
+ exports.default = LayoutGroup;
@@ -0,0 +1,5 @@
1
+ export interface ILayoutGroupOptions extends fabric.IObjectOptions {
2
+ _id?: string;
3
+ canvas?: fabric.Canvas;
4
+ objects?: fabric.Object[];
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,4 +3,5 @@ export declare const OBJECT_TYPES: {
3
3
  clipart: string;
4
4
  imagePlaceHolder: string;
5
5
  activeSelection: string;
6
+ layoutGroup: string;
6
7
  };
package/lib/constants.js CHANGED
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OBJECT_TYPES = void 0;
4
4
  const constants_1 = require("./ClipartObject/constants");
5
5
  const constants_2 = require("./ImagePlaceholderObject/constants");
6
- const constants_3 = require("./TextInputObject/constants");
6
+ const constants_3 = require("./LayoutGroupObject/constants");
7
+ const constants_4 = require("./TextInputObject/constants");
7
8
  exports.OBJECT_TYPES = {
8
- textInput: constants_3.TEXT_INPUT_OBJECT_ATTRIBUTES.type,
9
+ textInput: constants_4.TEXT_INPUT_OBJECT_ATTRIBUTES.type,
9
10
  clipart: constants_1.CLIPART_OBJECT_ATTRIBUTES.type,
10
11
  imagePlaceHolder: constants_2.IMAGE_PLACEHOLDER_OBJECT_ATTRIBUTES.type,
11
12
  activeSelection: "activeSelection",
13
+ layoutGroup: constants_3.LAYOUT_GROUP_OBJECT_ATTRIBUTES.type,
12
14
  };
package/lib/index.d.ts CHANGED
@@ -4,4 +4,5 @@ import ImagePlaceholder from "./ImagePlaceholderObject";
4
4
  import fabric, { lockObject, lockAllObjects, loadImageFromFile, loadImageFromUrl, getObject, asyncGetObject } from "./utils";
5
5
  import { OBJECT_TYPES } from "./constants";
6
6
  import { IMAGE_FILTER_TYPES } from "./ImagePlaceholderObject/constants";
7
- export { fabric, TextInput, Clipart, ImagePlaceholder, lockObject, lockAllObjects, loadImageFromFile, loadImageFromUrl, getObject, asyncGetObject, OBJECT_TYPES, IMAGE_FILTER_TYPES, };
7
+ import LayoutGroup from "./LayoutGroupObject";
8
+ export { fabric, TextInput, Clipart, ImagePlaceholder, LayoutGroup, lockObject, lockAllObjects, loadImageFromFile, loadImageFromUrl, getObject, asyncGetObject, OBJECT_TYPES, IMAGE_FILTER_TYPES, };
package/lib/index.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.IMAGE_FILTER_TYPES = exports.OBJECT_TYPES = exports.asyncGetObject = exports.getObject = exports.loadImageFromUrl = exports.loadImageFromFile = exports.lockAllObjects = exports.lockObject = exports.ImagePlaceholder = exports.Clipart = exports.TextInput = exports.fabric = void 0;
29
+ exports.IMAGE_FILTER_TYPES = exports.OBJECT_TYPES = exports.asyncGetObject = exports.getObject = exports.loadImageFromUrl = exports.loadImageFromFile = exports.lockAllObjects = exports.lockObject = exports.LayoutGroup = exports.ImagePlaceholder = exports.Clipart = exports.TextInput = exports.fabric = void 0;
30
30
  const TextInputObject_1 = __importDefault(require("./TextInputObject"));
31
31
  exports.TextInput = TextInputObject_1.default;
32
32
  const ClipartObject_1 = __importDefault(require("./ClipartObject"));
@@ -45,3 +45,5 @@ const constants_1 = require("./constants");
45
45
  Object.defineProperty(exports, "OBJECT_TYPES", { enumerable: true, get: function () { return constants_1.OBJECT_TYPES; } });
46
46
  const constants_2 = require("./ImagePlaceholderObject/constants");
47
47
  Object.defineProperty(exports, "IMAGE_FILTER_TYPES", { enumerable: true, get: function () { return constants_2.IMAGE_FILTER_TYPES; } });
48
+ const LayoutGroupObject_1 = __importDefault(require("./LayoutGroupObject"));
49
+ exports.LayoutGroup = LayoutGroupObject_1.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customized-fabric",
3
- "version": "1.4.9",
3
+ "version": "1.5.1",
4
4
  "description": "Customized fabric",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",