customized-fabric 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/LayoutGroupObject/constants.d.ts +4 -0
- package/lib/LayoutGroupObject/constants.js +7 -0
- package/lib/LayoutGroupObject/index.d.ts +16 -0
- package/lib/LayoutGroupObject/index.js +51 -0
- package/lib/LayoutGroupObject/interfaces.d.ts +5 -0
- package/lib/LayoutGroupObject/interfaces.js +2 -0
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +4 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/package.json +1 -1
@@ -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;
|
package/lib/constants.d.ts
CHANGED
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("./
|
6
|
+
const constants_3 = require("./LayoutGroupObject/constants");
|
7
|
+
const constants_4 = require("./TextInputObject/constants");
|
7
8
|
exports.OBJECT_TYPES = {
|
8
|
-
textInput:
|
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
|
-
|
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;
|