xctc-utils 1.6.67 → 1.6.69
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.
- package/README.md +1 -4
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.js +267 -266
- package/dist/crypto/index.js +16 -16
- package/dist/event/changed.js +13 -13
- package/dist/event/drop.js +6 -6
- package/dist/event/index.js +5 -5
- package/dist/event/mouse-down.js +6 -6
- package/dist/event/mouse-move.js +6 -6
- package/dist/event/mouse-up.js +8 -8
- package/dist/event/mouse-wheel.js +2 -2
- package/dist/format/index.js +1 -1
- package/dist/handle/create.js +84 -60
- package/dist/handle/index.js +9 -9
- package/dist/handle/query.js +22 -22
- package/dist/handle/register.js +3 -3
- package/dist/handle/update.js +17 -17
- package/dist/iframe/index.js +30 -30
- package/dist/index.js +29 -24
- package/dist/is/has.js +2 -2
- package/dist/is/index.js +4 -4
- package/dist/modal/index.js +32 -23
- package/dist/params/index.js +59 -59
- package/dist/storage/index.js +4 -4
- package/dist/test.js +3 -3
- package/dist/time/index.js +32 -32
- package/dist/update/index.d.ts +1 -0
- package/dist/update/index.js +48 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +46 -27
- package/dist/weixin/index.d.ts +1 -0
- package/dist/weixin/index.js +109 -106
- package/package.json +1 -1
- package/tsconfig.json +1 -1
package/dist/canvas/index.js
CHANGED
|
@@ -1,39 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
3
|
+
const config_1 = require("../config");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const is_1 = require("../is");
|
|
6
|
+
const has_1 = require("../is/has");
|
|
7
|
+
const register_1 = require("../handle/register");
|
|
8
|
+
const drop_1 = require("../event/drop");
|
|
9
|
+
const mouse_down_1 = require("../event/mouse-down");
|
|
10
|
+
const mouse_move_1 = require("../event/mouse-move");
|
|
11
|
+
const mouse_up_1 = require("../event/mouse-up");
|
|
12
|
+
const mouse_wheel_1 = require("../event/mouse-wheel");
|
|
13
|
+
const index_1 = require("../handle/index");
|
|
14
|
+
const drop_2 = require("../event/drop");
|
|
15
|
+
const create_1 = require("../handle/create");
|
|
16
|
+
const query_1 = require("../handle/query");
|
|
17
|
+
const update_1 = require("../handle/update");
|
|
18
|
+
const changed_1 = require("../event/changed");
|
|
19
|
+
const index_2 = require("../event/index");
|
|
31
20
|
// 初始化画布创建时需要的参数-默认值
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
const defaultConfig = { ...config_1.configDefaultValue.canvasDefaultValue };
|
|
22
|
+
class CanvasHooks {
|
|
23
|
+
constructor(config) {
|
|
35
24
|
this.fabricSource = null;
|
|
36
|
-
this.fabricUrlSource = "https://cdn.
|
|
25
|
+
this.fabricUrlSource = "https://cdn.bootcss.com/fabric.js/4.0.0-beta.5/fabric.min.js";
|
|
37
26
|
this.canvasDataSource = null;
|
|
38
27
|
this.zoomDataSource = "100";
|
|
39
28
|
this.canvasBackgroundImageTarget = null;
|
|
@@ -63,24 +52,26 @@ var CanvasHooks = /** @class */ (function () {
|
|
|
63
52
|
this.mouseWheelStatus = false;
|
|
64
53
|
this.defaultCreateDataListStatus = false;
|
|
65
54
|
this.mouseCanvasInRangeStatus = false;
|
|
55
|
+
const url = this.fabricUrlSource;
|
|
66
56
|
if (config === null || config === void 0 ? void 0 : config.init) {
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
(0, utils_1.loadScript)(url, () => {
|
|
58
|
+
// 是否默认加载画布
|
|
59
|
+
this.createCanvasFn();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
(0, utils_1.loadScript)(url);
|
|
69
64
|
}
|
|
70
65
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
enumerable: false,
|
|
76
|
-
configurable: true
|
|
77
|
-
});
|
|
66
|
+
get canvasConfigData() {
|
|
67
|
+
return this.canvasConfig;
|
|
68
|
+
}
|
|
78
69
|
// 创建画布
|
|
79
|
-
|
|
70
|
+
createCanvasFn(config) {
|
|
80
71
|
var _a;
|
|
81
|
-
|
|
72
|
+
const _ = this;
|
|
82
73
|
_.renderCanvasStatus = 1;
|
|
83
|
-
|
|
74
|
+
let canvasId = "";
|
|
84
75
|
// config 配置数据必须有画布ID参数
|
|
85
76
|
if ((0, is_1.isObject)(config) && !(0, has_1.hasProperty)(config, "id")) {
|
|
86
77
|
console.error("createCanvasFn函数接收的参数必须包含画布对应的id");
|
|
@@ -94,124 +85,135 @@ var CanvasHooks = /** @class */ (function () {
|
|
|
94
85
|
}
|
|
95
86
|
}
|
|
96
87
|
// 初始化画布渲染时的配置参数
|
|
97
|
-
|
|
88
|
+
const data = {
|
|
89
|
+
...defaultConfig,
|
|
90
|
+
..._.canvasConfig
|
|
91
|
+
};
|
|
98
92
|
if (!(0, has_1.hasProperty)(_.canvasConfig, "width")) {
|
|
99
93
|
data['width'] = _.elementSizeFn("canvasContainer").width;
|
|
100
94
|
}
|
|
101
95
|
if (!(0, has_1.hasProperty)(_.canvasConfig, "height")) {
|
|
102
96
|
data['height'] = _.elementSizeFn("canvasContainer").height;
|
|
103
97
|
}
|
|
104
|
-
|
|
105
|
-
console.log("canvas--options", data);
|
|
98
|
+
const imgUrl = (data === null || data === void 0 ? void 0 : data.backgroundImgUrl) || "";
|
|
106
99
|
canvasId = data.id;
|
|
107
|
-
|
|
100
|
+
let url = _.fabricUrlSource;
|
|
108
101
|
if ((_a = _.canvasConfig) === null || _a === void 0 ? void 0 : _a.fabricUrlSource) {
|
|
109
102
|
url = _.canvasConfig.fabricUrlSource;
|
|
110
103
|
}
|
|
111
104
|
if (config === null || config === void 0 ? void 0 : config.fabricUrlSource) {
|
|
112
105
|
url = config.fabricUrlSource;
|
|
113
106
|
}
|
|
114
|
-
(0, utils_1.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
107
|
+
if (!(0, utils_1.isScriptLoaded)(url)) {
|
|
108
|
+
(0, utils_1.loadScript)(url, () => {
|
|
109
|
+
_.initCanvasDataFn(imgUrl, canvasId, data);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
_.initCanvasDataFn(imgUrl, canvasId, data);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
initCanvasDataFn(imgUrl, canvasId, data) {
|
|
117
|
+
const _ = this;
|
|
118
|
+
const win = window;
|
|
119
|
+
_.fabricSource = (win === null || win === void 0 ? void 0 : win.fabric) || {};
|
|
120
|
+
if (imgUrl) {
|
|
121
|
+
_.fabricSource.Image.fromURL(imgUrl, function (img) {
|
|
122
|
+
_.renderCanvasStatus = 2;
|
|
123
|
+
_.canvasBackgroundImageTarget = img;
|
|
124
|
+
const { actions = "" } = _.canvasConfig;
|
|
125
|
+
const zoomValue = (actions === null || actions === void 0 ? void 0 : actions.zoom) || 1;
|
|
126
|
+
if (!_.canvasDataSource) {
|
|
127
|
+
_.canvasDataSource = new _.fabricSource.Canvas(canvasId, { ...data });
|
|
128
|
+
if (zoomValue != 1) {
|
|
129
|
+
_.canvasDataSource.setZoom(zoomValue);
|
|
128
130
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
131
|
+
}
|
|
132
|
+
const canvasWidth = _.canvasDataSource.getWidth();
|
|
133
|
+
const canvasHeight = _.canvasDataSource.getHeight();
|
|
134
|
+
const imgWidth = img.width;
|
|
135
|
+
const imgHeight = img.height;
|
|
136
|
+
let scaleX = 1;
|
|
137
|
+
let scaleY = 1;
|
|
138
|
+
if (canvasWidth && canvasHeight && imgWidth && imgHeight) {
|
|
139
|
+
let imageAspectRatio = imgWidth / imgHeight;
|
|
140
|
+
let canvasAspectRatio = canvasWidth / canvasHeight;
|
|
141
|
+
if (imageAspectRatio > canvasAspectRatio) {
|
|
142
|
+
// 图片更宽,基于高度缩放
|
|
143
|
+
scaleY = canvasHeight / imgHeight;
|
|
144
|
+
scaleX = scaleY * imageAspectRatio;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// 图片更高或宽高比相同,基于宽度缩放
|
|
148
|
+
scaleX = canvasWidth / imgWidth;
|
|
149
|
+
scaleY = scaleX / imageAspectRatio;
|
|
148
150
|
}
|
|
149
|
-
console.log("原始比例:", { scaleX: scaleX, scaleY: scaleY, width: imgWidth, height: imgHeight });
|
|
150
|
-
_.canvasDataSource.setBackgroundImage(img, _.canvasDataSource.renderAll.bind(_.canvasDataSource), {
|
|
151
|
-
originX: 'left',
|
|
152
|
-
originY: 'top',
|
|
153
|
-
left: 0,
|
|
154
|
-
top: 0,
|
|
155
|
-
// scaleX: scaleX,
|
|
156
|
-
// scaleY: scaleY,
|
|
157
|
-
width: imgWidth,
|
|
158
|
-
height: imgHeight,
|
|
159
|
-
});
|
|
160
|
-
_.renderCanvasStatus = 3;
|
|
161
|
-
_.registerAllEventHandleFn();
|
|
162
|
-
_.canvasDataSource.renderAll();
|
|
163
|
-
callBack(_.canvasDataSource);
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
if (!_.canvasDataSource) {
|
|
168
|
-
_.canvasDataSource = new _.fabricSource.Canvas(canvasId, __assign({}, data));
|
|
169
|
-
_.renderCanvasStatus = 3;
|
|
170
|
-
_.registerAllEventHandleFn();
|
|
171
|
-
_.canvasDataSource.renderAll();
|
|
172
|
-
callBack(_.canvasDataSource);
|
|
173
151
|
}
|
|
152
|
+
console.log("原始比例:", { scaleX: scaleX, scaleY: scaleY, width: imgWidth, height: imgHeight });
|
|
153
|
+
_.canvasDataSource.setBackgroundImage(img, _.canvasDataSource.renderAll.bind(_.canvasDataSource), {
|
|
154
|
+
originX: 'left',
|
|
155
|
+
originY: 'top',
|
|
156
|
+
left: 0,
|
|
157
|
+
top: 0,
|
|
158
|
+
// scaleX: scaleX,
|
|
159
|
+
// scaleY: scaleY,
|
|
160
|
+
width: imgWidth,
|
|
161
|
+
height: imgHeight,
|
|
162
|
+
});
|
|
163
|
+
_.renderCanvasStatus = 3;
|
|
164
|
+
_.registerAllEventHandleFn();
|
|
165
|
+
_.canvasDataSource.renderAll();
|
|
166
|
+
callBack(_.canvasDataSource);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
if (!_.canvasDataSource) {
|
|
171
|
+
_.canvasDataSource = new _.fabricSource.Canvas(canvasId, { ...data });
|
|
172
|
+
_.renderCanvasStatus = 3;
|
|
173
|
+
_.registerAllEventHandleFn();
|
|
174
|
+
_.canvasDataSource.renderAll();
|
|
175
|
+
callBack(_.canvasDataSource);
|
|
174
176
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
177
|
+
}
|
|
178
|
+
// 如果配置里面有回调函数,则将当前画布数据对象返回
|
|
179
|
+
function callBack(data) {
|
|
180
|
+
var _a;
|
|
181
|
+
const cb = ((_a = _.canvasConfig) === null || _a === void 0 ? void 0 : _a.cb) || "";
|
|
182
|
+
// 获取DOM元素
|
|
183
|
+
const targetElement = (0, utils_1.getDomFn)("canvasContainer");
|
|
184
|
+
// 添加事件监听器
|
|
185
|
+
document.addEventListener('mousemove', (0, index_2.checkMouseInElement)(targetElement));
|
|
186
|
+
if (cb instanceof Function) {
|
|
187
|
+
cb(data);
|
|
186
188
|
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
189
191
|
// 销毁画布
|
|
190
|
-
|
|
192
|
+
disposeCanvasFn() {
|
|
191
193
|
var _a, _b;
|
|
192
194
|
if (this.canvasDataSource) {
|
|
193
|
-
|
|
195
|
+
const el = (_a = this.canvasDataSource) === null || _a === void 0 ? void 0 : _a.getElement();
|
|
194
196
|
(_b = this.canvasDataSource) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
195
197
|
el === null || el === void 0 ? void 0 : el.remove(); // 删除canvasDataSource元素
|
|
196
198
|
this.canvasDataSource = null;
|
|
197
199
|
}
|
|
198
|
-
}
|
|
200
|
+
}
|
|
199
201
|
// 关于画布相关配置数据
|
|
200
|
-
|
|
202
|
+
canvasConfigDataFn(config) {
|
|
201
203
|
/**
|
|
202
204
|
* rightButtonsDataSource 画布右键菜单列表数据
|
|
203
205
|
*/
|
|
204
206
|
this.canvasHandleConfig = config || {};
|
|
205
|
-
}
|
|
207
|
+
}
|
|
206
208
|
// 注册回调事件--页面生成画布实例的时候,调用该函数
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
209
|
+
registerCallBackEventFn(config) {
|
|
210
|
+
const _ = this;
|
|
211
|
+
const boundFunction = register_1.RegisterCanvasEventFn.bind(_, config);
|
|
210
212
|
boundFunction();
|
|
211
|
-
}
|
|
213
|
+
}
|
|
212
214
|
// 执行注册事件
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
registerAllEventHandleFn() {
|
|
216
|
+
const _ = this;
|
|
215
217
|
_.dragLastPosDataSource = {
|
|
216
218
|
open: false,
|
|
217
219
|
lastPosX: null,
|
|
@@ -239,14 +241,14 @@ var CanvasHooks = /** @class */ (function () {
|
|
|
239
241
|
_.registerMouseUpEventFn(options);
|
|
240
242
|
});
|
|
241
243
|
// 注册滚动事件
|
|
242
|
-
_.canvasDataSource.on('mouse:wheel',
|
|
244
|
+
_.canvasDataSource.on('mouse:wheel', (options) => {
|
|
243
245
|
_.registerMouseWheelEventFn(options);
|
|
244
246
|
});
|
|
245
|
-
_.canvasDataSource.on('drop',
|
|
247
|
+
_.canvasDataSource.on('drop', (options) => {
|
|
246
248
|
_.registerMouseDropEventFn(options);
|
|
247
249
|
});
|
|
248
250
|
//监听画布缩放状态
|
|
249
|
-
_.canvasDataSource.on('zoom:changed',
|
|
251
|
+
_.canvasDataSource.on('zoom:changed', (options) => {
|
|
250
252
|
_.registerCanvasZoomChangeEventFn(options);
|
|
251
253
|
});
|
|
252
254
|
_.canvasDataSource.on('contextmenu', function (options) {
|
|
@@ -258,206 +260,205 @@ var CanvasHooks = /** @class */ (function () {
|
|
|
258
260
|
document.body.addEventListener('contextmenu', function (event) {
|
|
259
261
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
260
262
|
});
|
|
261
|
-
}
|
|
263
|
+
}
|
|
262
264
|
// 注册画布发生缩放监听事件
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
265
|
+
registerCanvasZoomChangeEventFn() {
|
|
266
|
+
const _ = this;
|
|
267
|
+
const boundFunction = register_1.RegisterCanvasZoomChangeEventFn.bind(_);
|
|
266
268
|
boundFunction();
|
|
267
|
-
}
|
|
269
|
+
}
|
|
268
270
|
// 拖拽事件注册
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
271
|
+
registerMouseDropEventFn(options) {
|
|
272
|
+
const _ = this;
|
|
273
|
+
const boundFunction = drop_1.RegisterMouseDropEventFn.bind(_, options);
|
|
272
274
|
boundFunction();
|
|
273
|
-
}
|
|
275
|
+
}
|
|
274
276
|
// 鼠标进入画布
|
|
275
|
-
|
|
276
|
-
|
|
277
|
+
registerMouseOverEventFn(options) {
|
|
278
|
+
const _ = this;
|
|
277
279
|
_.mouseCanvasInRangeStatus = true;
|
|
278
|
-
}
|
|
280
|
+
}
|
|
279
281
|
// 鼠标移出画布
|
|
280
|
-
|
|
282
|
+
registerMouseOutEventFn(options) {
|
|
281
283
|
// console.log("registerMouseOutEventFn");
|
|
282
|
-
|
|
284
|
+
const _ = this;
|
|
283
285
|
_.mouseCanvasInRangeStatus = false;
|
|
284
|
-
}
|
|
286
|
+
}
|
|
285
287
|
// 注册鼠标按下事件
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
288
|
+
registerMouseDownEventFn(options) {
|
|
289
|
+
const _ = this;
|
|
290
|
+
const boundFunction = mouse_down_1.RegisterMouseDownEventFn.bind(_, options);
|
|
289
291
|
boundFunction();
|
|
290
|
-
}
|
|
292
|
+
}
|
|
291
293
|
// 注册鼠标移动事件
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
294
|
+
registerMouseMoveEventFn(options) {
|
|
295
|
+
const _ = this;
|
|
296
|
+
const boundFunction = mouse_move_1.RegisterMouseMoveEventFn.bind(_, options);
|
|
295
297
|
boundFunction();
|
|
296
|
-
}
|
|
298
|
+
}
|
|
297
299
|
// 注册鼠标抬起事件
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
300
|
+
registerMouseUpEventFn(options) {
|
|
301
|
+
const _ = this;
|
|
302
|
+
const boundFunction = mouse_up_1.RegisterMouseUpEventFn.bind(_, options);
|
|
301
303
|
boundFunction();
|
|
302
|
-
}
|
|
304
|
+
}
|
|
303
305
|
// 注册鼠标滚动事件
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
306
|
+
registerMouseWheelEventFn(options) {
|
|
307
|
+
const _ = this;
|
|
308
|
+
const boundFunction = mouse_wheel_1.RegisterMouseWheelEventFn.bind(_, options);
|
|
307
309
|
boundFunction();
|
|
308
|
-
}
|
|
310
|
+
}
|
|
309
311
|
// 滚动事件操作--画布缩放监听
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
312
|
+
registerZoomHandleFn(options) {
|
|
313
|
+
const _ = this;
|
|
314
|
+
const boundFunction = index_1.RegisterZoomHandleFn.bind(_, options);
|
|
313
315
|
boundFunction();
|
|
314
|
-
}
|
|
316
|
+
}
|
|
315
317
|
// 页面上发生拖拽时,拖拽完成后的数据存储函数
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
318
|
+
dragCreateElementDataFn(data) {
|
|
319
|
+
const _ = this;
|
|
320
|
+
const boundFunction = drop_2.DragCreateElementDataFn.bind(_, data);
|
|
319
321
|
boundFunction();
|
|
320
|
-
}
|
|
322
|
+
}
|
|
321
323
|
// 拖拽进入画布元素创建
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
324
|
+
createDragElementFn() {
|
|
325
|
+
const _ = this;
|
|
326
|
+
const boundFunction = create_1.CreateDragElementFn.bind(_);
|
|
325
327
|
boundFunction();
|
|
326
|
-
}
|
|
328
|
+
}
|
|
327
329
|
// 默认加载一个列表数据到画布
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
330
|
+
initElement2CanvasFn(list) {
|
|
331
|
+
const _ = this;
|
|
332
|
+
const boundFunction = create_1.InitElement2CanvasFn.bind(_, list);
|
|
331
333
|
boundFunction();
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
}
|
|
335
|
+
getCreateElementStatusFn(index) {
|
|
336
|
+
const _ = this;
|
|
337
|
+
const list = _.defaultCreateDataList;
|
|
336
338
|
if (index >= 0 && (list === null || list === void 0 ? void 0 : list.length)) {
|
|
337
339
|
if (index == list.length - 1) {
|
|
338
|
-
setTimeout(
|
|
340
|
+
setTimeout(() => {
|
|
339
341
|
_.resetElementSizeFn();
|
|
340
342
|
}, 100);
|
|
341
343
|
}
|
|
342
344
|
}
|
|
343
|
-
}
|
|
345
|
+
}
|
|
344
346
|
// 创建SVG到画布
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
347
|
+
createCanvasSvgElementFn(item, index) {
|
|
348
|
+
const _ = this;
|
|
349
|
+
const boundFunction = create_1.CreateCanvasSvgElementFn.bind(_, item, index);
|
|
348
350
|
boundFunction();
|
|
349
|
-
}
|
|
351
|
+
}
|
|
350
352
|
// 创建图片到画布
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
353
|
+
createCanvasImageElementFn(item, index) {
|
|
354
|
+
const _ = this;
|
|
355
|
+
const boundFunction = create_1.CreateCanvasImageElementFn.bind(_, item, index);
|
|
354
356
|
boundFunction();
|
|
355
|
-
}
|
|
357
|
+
}
|
|
356
358
|
// 获取到所有被框选的对象
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
359
|
+
getSelectionAllElementsFn() {
|
|
360
|
+
const _ = this;
|
|
361
|
+
const data = query_1.QuerySelectionAllElementsFn.bind(_);
|
|
360
362
|
return data();
|
|
361
|
-
}
|
|
363
|
+
}
|
|
362
364
|
// 获取到指定选择框内被框选的对象
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
365
|
+
getSelectionElementsFn(item) {
|
|
366
|
+
const _ = this;
|
|
367
|
+
const data = query_1.QuerySelectionElementsFn.bind(_, item);
|
|
366
368
|
return data();
|
|
367
|
-
}
|
|
369
|
+
}
|
|
368
370
|
// 创建自定义图像
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
371
|
+
createSelectionRectFn() {
|
|
372
|
+
const _ = this;
|
|
373
|
+
const boundFunction = create_1.CreateSelectionRectFn.bind(_);
|
|
372
374
|
boundFunction();
|
|
373
|
-
}
|
|
375
|
+
}
|
|
374
376
|
// 创建全选框
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
377
|
+
createAllSelectionRectFn() {
|
|
378
|
+
const _ = this;
|
|
379
|
+
const boundFunction = create_1.CreateAllSelectionRectFn.bind(_);
|
|
378
380
|
boundFunction();
|
|
379
|
-
}
|
|
381
|
+
}
|
|
380
382
|
// 删除全选对象选择框
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
383
|
+
removeAllSelectionRectFn() {
|
|
384
|
+
const _ = this;
|
|
385
|
+
const boundFunction = update_1.RemoveAllSelectionRectFn.bind(_);
|
|
384
386
|
boundFunction();
|
|
385
|
-
}
|
|
387
|
+
}
|
|
386
388
|
// 自定义选择框绘制数据更新
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
updateSelectionRectFn(options) {
|
|
390
|
+
const _ = this;
|
|
391
|
+
const boundFunction = update_1.UpdateSelectionRectFn.bind(_, options);
|
|
390
392
|
boundFunction();
|
|
391
|
-
}
|
|
393
|
+
}
|
|
392
394
|
// 自定义选择框绘制完成
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
395
|
+
createSelectionRectFinishFn() {
|
|
396
|
+
const _ = this;
|
|
397
|
+
const boundFunction = update_1.CreateSelectionRectFinishFn.bind(_);
|
|
396
398
|
boundFunction();
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
399
|
+
}
|
|
400
|
+
init() {
|
|
401
|
+
const _ = this;
|
|
402
|
+
}
|
|
401
403
|
// 获取画布容器的宽高
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
404
|
+
elementSizeFn(id) {
|
|
405
|
+
const _ = this;
|
|
406
|
+
const data = query_1.QueryElementSizeFn.bind(_, id);
|
|
407
|
+
const result = data() || {};
|
|
406
408
|
console.log("elementSizeFn--result==", result);
|
|
407
409
|
return result;
|
|
408
|
-
}
|
|
410
|
+
}
|
|
409
411
|
// 右键菜单管理
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
412
|
+
createRightClickMenuFn(options) {
|
|
413
|
+
const _ = this;
|
|
414
|
+
const boundFunction = create_1.CreateRightClickMenuFn.bind(_, options);
|
|
413
415
|
boundFunction();
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
}
|
|
417
|
+
hiddenRightClickMenuFn() {
|
|
418
|
+
const _ = this;
|
|
419
|
+
const boundFunction = update_1.HiddenRightClickMenuFn.bind(_);
|
|
418
420
|
boundFunction();
|
|
419
|
-
}
|
|
421
|
+
}
|
|
420
422
|
// 在画布上动态创建对象
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
423
|
+
createElementFn(domVal, id, index) {
|
|
424
|
+
const _ = this;
|
|
425
|
+
const data = create_1.CreateElementFn.bind(_, domVal, id, index);
|
|
424
426
|
return data();
|
|
425
|
-
}
|
|
427
|
+
}
|
|
426
428
|
// 执行返回上一步操作
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
429
|
+
previousStepFn() {
|
|
430
|
+
const _ = this;
|
|
431
|
+
const boundFunction = changed_1.PreviousStepFn.bind(_);
|
|
430
432
|
boundFunction();
|
|
431
|
-
}
|
|
433
|
+
}
|
|
432
434
|
// 移除画布上指定对象
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
435
|
+
removeElementFn(id) {
|
|
436
|
+
const _ = this;
|
|
437
|
+
const boundFunction = update_1.RemoveElementFn.bind(_, id);
|
|
436
438
|
boundFunction();
|
|
437
|
-
}
|
|
439
|
+
}
|
|
438
440
|
// 清空画布上所有对象
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
441
|
+
removeAllElementFn() {
|
|
442
|
+
const _ = this;
|
|
443
|
+
const boundFunction = update_1.RemoveAllElementFn.bind(_);
|
|
442
444
|
boundFunction();
|
|
443
|
-
}
|
|
445
|
+
}
|
|
444
446
|
// 对于画布出现缩放的情况,加载进入的数据会产生偏移处理
|
|
445
447
|
// 问题未解决,备注
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
448
|
+
resetElementSizeFn() {
|
|
449
|
+
const _ = this;
|
|
450
|
+
const boundFunction = changed_1.ResetElementSizeFn.bind(_);
|
|
449
451
|
boundFunction();
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
452
|
+
}
|
|
453
|
+
setCanvasBaseConfigFn(zoom) {
|
|
454
|
+
const _ = this;
|
|
455
|
+
const boundFunction = index_1.SetCanvasBaseConfigFn.bind(_, zoom);
|
|
454
456
|
boundFunction();
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
457
|
+
}
|
|
458
|
+
getCanvasActionDataFn() {
|
|
459
|
+
const _ = this;
|
|
460
|
+
const data = query_1.QueryCanvasActionDataFn.bind(_);
|
|
459
461
|
return data();
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
}());
|
|
462
|
+
}
|
|
463
|
+
}
|
|
463
464
|
exports.default = CanvasHooks;
|