@tmagic/stage 1.2.0-beta.2 → 1.2.0-beta.21

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.
Files changed (41) hide show
  1. package/README.md +62 -1
  2. package/dist/tmagic-stage.js +2157 -0
  3. package/dist/tmagic-stage.js.map +1 -0
  4. package/dist/{tmagic-stage.umd.js → tmagic-stage.umd.cjs} +1436 -993
  5. package/dist/tmagic-stage.umd.cjs.map +1 -0
  6. package/package.json +9 -8
  7. package/src/ActionManager.ts +534 -0
  8. package/src/DragResizeHelper.ts +338 -0
  9. package/src/MoveableOptionsManager.ts +249 -0
  10. package/src/MoveableSelectParentAble.ts +76 -0
  11. package/src/Rule.ts +13 -9
  12. package/src/StageCore.ts +220 -260
  13. package/src/StageDragResize.ts +83 -339
  14. package/src/StageHighlight.ts +17 -16
  15. package/src/StageMask.ts +88 -140
  16. package/src/StageMultiDragResize.ts +97 -198
  17. package/src/StageRender.ts +90 -15
  18. package/src/TargetShadow.ts +120 -0
  19. package/src/const.ts +1 -1
  20. package/src/types.ts +97 -19
  21. package/src/util.ts +24 -11
  22. package/types/ActionManager.d.ts +141 -0
  23. package/types/DragResizeHelper.d.ts +70 -0
  24. package/types/MoveableOptionsManager.d.ts +86 -0
  25. package/types/MoveableSelectParentAble.d.ts +8 -0
  26. package/types/Rule.d.ts +4 -3
  27. package/types/StageCore.d.ts +65 -39
  28. package/types/StageDragResize.d.ts +11 -40
  29. package/types/StageHighlight.d.ts +3 -4
  30. package/types/StageMask.d.ts +23 -22
  31. package/types/StageMultiDragResize.d.ts +8 -24
  32. package/types/StageRender.d.ts +24 -6
  33. package/types/TargetShadow.d.ts +22 -0
  34. package/types/const.d.ts +1 -1
  35. package/types/types.d.ts +85 -18
  36. package/types/util.d.ts +9 -8
  37. package/dist/tmagic-stage.mjs +0 -1715
  38. package/dist/tmagic-stage.mjs.map +0 -1
  39. package/dist/tmagic-stage.umd.js.map +0 -1
  40. package/src/TargetCalibrate.ts +0 -119
  41. package/types/TargetCalibrate.d.ts +0 -20
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('events'), require('@tmagic/utils'), require('keycon'), require('moveable'), require('moveable-helper'), require('lodash-es'), require('@scena/guides')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'events', '@tmagic/utils', 'keycon', 'moveable', 'moveable-helper', 'lodash-es', '@scena/guides'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicStage = {}, global.EventEmitter, global.utils, global.KeyController, global.Moveable, global.MoveableHelper, global.lodashEs, global.Guides));
5
- })(this, (function (exports, EventEmitter, utils, KeyController, Moveable, MoveableHelper, lodashEs, Guides) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('events'), require('keycon'), require('lodash-es'), require('@tmagic/core'), require('@tmagic/utils'), require('moveable'), require('moveable-helper'), require('@scena/guides')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'events', 'keycon', 'lodash-es', '@tmagic/core', '@tmagic/utils', 'moveable', 'moveable-helper', '@scena/guides'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicStage = {}, global.EventEmitter, global.KeyController, global.lodashEs, global.core, global.utils, global.Moveable, global.MoveableHelper, global.Guides));
5
+ })(this, (function (exports, EventEmitter, KeyController, lodashEs, core, utils, Moveable, MoveableHelper, Guides) { 'use strict';
6
6
 
7
7
  const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
8
8
 
@@ -15,7 +15,7 @@
15
15
  const GHOST_EL_ID_PREFIX = "ghost_el_";
16
16
  const DRAG_EL_ID_PREFIX = "drag_el_";
17
17
  const HIGHLIGHT_EL_ID_PREFIX = "highlight_el_";
18
- const CONTAINER_HIGHLIGHT_CLASS = "tmagic-stage-container-highlight";
18
+ const CONTAINER_HIGHLIGHT_CLASS_NAME = "tmagic-stage-container-highlight";
19
19
  const PAGE_CLASS = "magic-ui-page";
20
20
  const DEFAULT_ZOOM = 1;
21
21
  var GuidesType = /* @__PURE__ */ ((GuidesType2) => {
@@ -45,18 +45,6 @@
45
45
  })(Mode || {});
46
46
  const SELECTED_CLASS = "tmagic-stage-selected-area";
47
47
 
48
- var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
49
- ContainerHighlightType2["DEFAULT"] = "default";
50
- ContainerHighlightType2["ALT"] = "alt";
51
- return ContainerHighlightType2;
52
- })(ContainerHighlightType || {});
53
- var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
54
- StageDragStatus2["START"] = "start";
55
- StageDragStatus2["ING"] = "ing";
56
- StageDragStatus2["END"] = "end";
57
- return StageDragStatus2;
58
- })(StageDragStatus || {});
59
-
60
48
  const getParents = (el, relative) => {
61
49
  let cur = el.parentElement;
62
50
  const parents = [];
@@ -67,9 +55,10 @@
67
55
  return parents;
68
56
  };
69
57
  const getOffset = (el) => {
70
- const { offsetParent } = el;
71
- const left = el.offsetLeft;
72
- const top = el.offsetTop;
58
+ const htmlEl = el;
59
+ const { offsetParent } = htmlEl;
60
+ const left = htmlEl.offsetLeft || 0;
61
+ const top = htmlEl.offsetTop || 0;
73
62
  if (offsetParent) {
74
63
  const parentOffset = getOffset(offsetParent);
75
64
  return {
@@ -82,7 +71,7 @@
82
71
  top
83
72
  };
84
73
  };
85
- const getTargetElStyle = (el) => {
74
+ const getTargetElStyle = (el, zIndex) => {
86
75
  const offset = getOffset(el);
87
76
  const { transform } = getComputedStyle(el);
88
77
  return `
@@ -92,7 +81,7 @@
92
81
  top: ${offset.top}px;
93
82
  width: ${el.clientWidth}px;
94
83
  height: ${el.clientHeight}px;
95
- z-index: ${ZIndex.DRAG_EL};
84
+ ${typeof zIndex !== "undefined" ? `z-index: ${zIndex};` : ""}
96
85
  `;
97
86
  };
98
87
  const getAbsolutePosition = (el, { top, left }) => {
@@ -141,6 +130,8 @@
141
130
  return null;
142
131
  for (let parent = element; parent.parentElement; ) {
143
132
  parent = parent.parentElement;
133
+ if (parent.tagName === "HTML")
134
+ return parent;
144
135
  style = getComputedStyle(parent);
145
136
  if (isAbsolute(style) && isStatic(style))
146
137
  continue;
@@ -225,144 +216,500 @@
225
216
  dist: upEls.length && swapIndex > -1 ? upEls[swapIndex].id : target.id
226
217
  };
227
218
  };
219
+ const isMoveableButton = (target) => target.classList.contains("moveable-button") || target.parentElement?.classList.contains("moveable-button");
228
220
 
229
- class StageDragResize extends EventEmitter.EventEmitter {
230
- core;
231
- mask;
221
+ class TargetShadow {
222
+ el;
223
+ els = [];
224
+ idPrefix = "target_calibrate_";
232
225
  container;
226
+ scrollLeft = 0;
227
+ scrollTop = 0;
228
+ zIndex;
229
+ updateDragEl;
230
+ constructor(config) {
231
+ this.container = config.container;
232
+ if (config.updateDragEl) {
233
+ this.updateDragEl = config.updateDragEl;
234
+ }
235
+ if (typeof config.zIndex !== "undefined") {
236
+ this.zIndex = config.zIndex;
237
+ }
238
+ if (config.idPrefix) {
239
+ this.idPrefix = config.idPrefix;
240
+ }
241
+ this.container.addEventListener("customScroll", this.scrollHandler);
242
+ }
243
+ update(target) {
244
+ this.el = this.updateEl(target, this.el);
245
+ return this.el;
246
+ }
247
+ updateGroup(targetGroup) {
248
+ if (this.els.length > targetGroup.length) {
249
+ this.els.slice(targetGroup.length - 1).forEach((el) => {
250
+ el.remove();
251
+ });
252
+ }
253
+ this.els = targetGroup.map((target, index) => this.updateEl(target, this.els[index]));
254
+ return this.els;
255
+ }
256
+ destroyEl() {
257
+ this.el?.remove();
258
+ this.el = void 0;
259
+ }
260
+ destroyEls() {
261
+ this.els.forEach((el) => {
262
+ el.remove();
263
+ });
264
+ this.els = [];
265
+ }
266
+ destroy() {
267
+ this.container.removeEventListener("customScroll", this.scrollHandler);
268
+ this.destroyEl();
269
+ this.destroyEls();
270
+ }
271
+ updateEl(target, src) {
272
+ const el = src || globalThis.document.createElement("div");
273
+ el.id = `${this.idPrefix}${target.id}`;
274
+ el.style.cssText = getTargetElStyle(target, this.zIndex);
275
+ if (typeof this.updateDragEl === "function") {
276
+ this.updateDragEl(el, target);
277
+ }
278
+ const isFixed = isFixedParent(target);
279
+ const mode = this.container.dataset.mode || Mode.ABSOLUTE;
280
+ if (isFixed && mode !== Mode.FIXED) {
281
+ el.style.transform = `translate3d(${this.scrollLeft}px, ${this.scrollTop}px, 0)`;
282
+ } else if (!isFixed && mode === Mode.FIXED) {
283
+ el.style.transform = `translate3d(${-this.scrollLeft}px, ${-this.scrollTop}px, 0)`;
284
+ }
285
+ if (!globalThis.document.getElementById(el.id)) {
286
+ this.container.append(el);
287
+ }
288
+ return el;
289
+ }
290
+ scrollHandler = (e) => {
291
+ this.scrollLeft = e.detail.scrollLeft;
292
+ this.scrollTop = e.detail.scrollTop;
293
+ };
294
+ }
295
+
296
+ class DragResizeHelper {
297
+ targetShadow;
233
298
  target;
234
- dragEl;
235
- moveable;
236
- horizontalGuidelines = [];
237
- verticalGuidelines = [];
238
- elementGuidelines = [];
239
- mode = Mode.ABSOLUTE;
240
- moveableOptions = {};
241
- dragStatus = StageDragStatus.END;
242
- ghostEl;
299
+ targetList = [];
243
300
  moveableHelper;
244
- isContainerHighlight = false;
301
+ ghostEl;
302
+ frameSnapShot = {
303
+ left: 0,
304
+ top: 0
305
+ };
306
+ framesSnapShot = [];
307
+ mode = Mode.ABSOLUTE;
245
308
  constructor(config) {
246
- super();
247
- this.core = config.core;
248
- this.container = config.container;
249
- this.mask = config.mask;
250
- KeyController__default.default.global.keydown("alt", (e) => {
251
- e.inputEvent.preventDefault();
252
- this.isContainerHighlight = true;
309
+ this.moveableHelper = MoveableHelper__default.default.create({
310
+ useBeforeRender: true,
311
+ useRender: false,
312
+ createAuto: true
253
313
  });
254
- KeyController__default.default.global.keyup("alt", (e) => {
255
- e.inputEvent.preventDefault();
256
- const doc = this.core.renderer.contentWindow?.document;
257
- if (doc && this.canContainerHighlight()) {
258
- utils.removeClassNameByClassName(doc, this.core.containerHighlightClassName);
259
- }
260
- this.isContainerHighlight = false;
314
+ this.targetShadow = new TargetShadow({
315
+ container: config.container,
316
+ updateDragEl: config.updateDragEl,
317
+ zIndex: ZIndex.DRAG_EL,
318
+ idPrefix: DRAG_EL_ID_PREFIX
261
319
  });
262
320
  }
263
- select(el, event) {
264
- const oldTarget = this.target;
321
+ destroy() {
322
+ this.targetShadow.destroy();
323
+ this.destroyGhostEl();
324
+ this.moveableHelper.clear();
325
+ }
326
+ destroyShadowEl() {
327
+ this.targetShadow.destroyEl();
328
+ }
329
+ getShadowEl() {
330
+ return this.targetShadow.el;
331
+ }
332
+ updateShadowEl(el) {
333
+ this.destroyGhostEl();
265
334
  this.target = el;
266
- if (!this.dragEl) {
267
- this.dragEl = globalThis.document.createElement("div");
268
- this.container.append(this.dragEl);
269
- }
270
- if (!this.moveable || this.target !== oldTarget) {
271
- this.init(el);
272
- this.moveableHelper = MoveableHelper__default.default.create({
273
- useBeforeRender: true,
274
- useRender: false,
275
- createAuto: true
276
- });
277
- this.initMoveable();
335
+ this.targetShadow.update(el);
336
+ }
337
+ setMode(mode) {
338
+ this.mode = mode;
339
+ }
340
+ onResizeStart(e) {
341
+ this.moveableHelper.onResizeStart(e);
342
+ this.frameSnapShot.top = this.target.offsetTop;
343
+ this.frameSnapShot.left = this.target.offsetLeft;
344
+ }
345
+ onResize(e) {
346
+ const { width, height, drag } = e;
347
+ const { beforeTranslate } = drag;
348
+ if (this.mode === Mode.SORTABLE) {
349
+ this.target.style.top = "0px";
350
+ if (this.targetShadow.el) {
351
+ this.targetShadow.el.style.width = `${width}px`;
352
+ this.targetShadow.el.style.height = `${height}px`;
353
+ }
278
354
  } else {
279
- this.updateMoveable();
355
+ this.moveableHelper.onResize(e);
356
+ this.target.style.left = `${this.frameSnapShot.left + beforeTranslate[0]}px`;
357
+ this.target.style.top = `${this.frameSnapShot.top + beforeTranslate[1]}px`;
280
358
  }
281
- if (event) {
282
- this.moveable?.dragStart(event);
359
+ this.target.style.width = `${width}px`;
360
+ this.target.style.height = `${height}px`;
361
+ }
362
+ onDragStart(e) {
363
+ this.moveableHelper.onDragStart(e);
364
+ if (this.mode === Mode.SORTABLE) {
365
+ this.ghostEl = this.generateGhostEl(this.target);
283
366
  }
367
+ this.frameSnapShot.top = this.target.offsetTop;
368
+ this.frameSnapShot.left = this.target.offsetLeft;
284
369
  }
285
- updateMoveable(el = this.target) {
286
- if (!this.moveable)
287
- throw new Error("\u672A\u521D\u59CB\u5316moveable");
288
- if (!el)
289
- throw new Error("\u672A\u9009\u4E2D\u4EFB\u4F55\u8282\u70B9");
290
- this.target = el;
291
- this.init(el);
292
- Object.entries(this.moveableOptions).forEach(([key, value]) => {
293
- this.moveable[key] = value;
370
+ onDrag(e) {
371
+ if (this.ghostEl) {
372
+ this.ghostEl.style.top = `${this.frameSnapShot.top + e.beforeTranslate[1]}px`;
373
+ return;
374
+ }
375
+ this.moveableHelper.onDrag(e);
376
+ this.target.style.left = `${this.frameSnapShot.left + e.beforeTranslate[0]}px`;
377
+ this.target.style.top = `${this.frameSnapShot.top + e.beforeTranslate[1]}px`;
378
+ }
379
+ onRotateStart(e) {
380
+ this.moveableHelper.onRotateStart(e);
381
+ }
382
+ onRotate(e) {
383
+ this.moveableHelper.onRotate(e);
384
+ const frame = this.moveableHelper.getFrame(e.target);
385
+ this.target.style.transform = frame?.toCSSObject().transform || "";
386
+ }
387
+ onScaleStart(e) {
388
+ this.moveableHelper.onScaleStart(e);
389
+ }
390
+ onScale(e) {
391
+ this.moveableHelper.onScale(e);
392
+ const frame = this.moveableHelper.getFrame(e.target);
393
+ this.target.style.transform = frame?.toCSSObject().transform || "";
394
+ }
395
+ getGhostEl() {
396
+ return this.ghostEl;
397
+ }
398
+ destroyGhostEl() {
399
+ this.ghostEl?.remove();
400
+ this.ghostEl = void 0;
401
+ }
402
+ clear() {
403
+ this.moveableHelper.clear();
404
+ }
405
+ getFrame(el) {
406
+ return this.moveableHelper.getFrame(el);
407
+ }
408
+ getShadowEls() {
409
+ return this.targetShadow.els;
410
+ }
411
+ updateGroup(els) {
412
+ this.targetList = els;
413
+ this.framesSnapShot = [];
414
+ this.targetShadow.updateGroup(els);
415
+ }
416
+ setTargetList(targetList) {
417
+ this.targetList = targetList;
418
+ }
419
+ clearMultiSelectStatus() {
420
+ this.targetList = [];
421
+ this.targetShadow.destroyEls();
422
+ }
423
+ onResizeGroupStart(e) {
424
+ const { events } = e;
425
+ this.moveableHelper.onResizeGroupStart(e);
426
+ this.setFramesSnapShot(events);
427
+ }
428
+ onResizeGroup(e) {
429
+ const { events } = e;
430
+ events.forEach((ev) => {
431
+ const { width, height, beforeTranslate } = ev.drag;
432
+ const frameSnapShot = this.framesSnapShot.find(
433
+ (frameItem) => frameItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
434
+ );
435
+ if (!frameSnapShot)
436
+ return;
437
+ const targeEl = this.targetList.find(
438
+ (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
439
+ );
440
+ if (!targeEl)
441
+ return;
442
+ const isParentIncluded = this.targetList.find((targetItem) => targetItem.id === targeEl.parentElement?.id);
443
+ if (!isParentIncluded) {
444
+ targeEl.style.left = `${frameSnapShot.left + beforeTranslate[0]}px`;
445
+ targeEl.style.top = `${frameSnapShot.top + beforeTranslate[1]}px`;
446
+ }
447
+ targeEl.style.width = `${width}px`;
448
+ targeEl.style.height = `${height}px`;
294
449
  });
295
- this.moveable.updateTarget();
450
+ this.moveableHelper.onResizeGroup(e);
451
+ }
452
+ onDragGroupStart(e) {
453
+ const { events } = e;
454
+ this.moveableHelper.onDragGroupStart(e);
455
+ this.setFramesSnapShot(events);
456
+ }
457
+ onDragGroup(e) {
458
+ const { events } = e;
459
+ events.forEach((ev) => {
460
+ const frameSnapShot = this.framesSnapShot.find(
461
+ (frameItem) => frameItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
462
+ );
463
+ if (!frameSnapShot)
464
+ return;
465
+ const targeEl = this.targetList.find(
466
+ (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
467
+ );
468
+ if (!targeEl)
469
+ return;
470
+ const isParentIncluded = this.targetList.find((targetItem) => targetItem.id === targeEl.parentElement?.id);
471
+ if (!isParentIncluded) {
472
+ targeEl.style.left = `${frameSnapShot.left + ev.beforeTranslate[0]}px`;
473
+ targeEl.style.top = `${frameSnapShot.top + ev.beforeTranslate[1]}px`;
474
+ }
475
+ });
476
+ this.moveableHelper.onDragGroup(e);
477
+ }
478
+ setFramesSnapShot(events) {
479
+ if (this.framesSnapShot.length > 0)
480
+ return;
481
+ events.forEach((ev) => {
482
+ const matchEventTarget = this.targetList.find(
483
+ (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
484
+ );
485
+ if (!matchEventTarget)
486
+ return;
487
+ this.framesSnapShot.push({
488
+ left: matchEventTarget.offsetLeft,
489
+ top: matchEventTarget.offsetTop,
490
+ id: matchEventTarget.id
491
+ });
492
+ });
493
+ }
494
+ generateGhostEl(el) {
495
+ if (this.ghostEl) {
496
+ this.destroyGhostEl();
497
+ }
498
+ const ghostEl = el.cloneNode(true);
499
+ this.setGhostElChildrenId(ghostEl);
500
+ const { top, left } = getAbsolutePosition(el, getOffset(el));
501
+ ghostEl.id = `${GHOST_EL_ID_PREFIX}${el.id}`;
502
+ ghostEl.style.zIndex = ZIndex.GHOST_EL;
503
+ ghostEl.style.opacity = ".5";
504
+ ghostEl.style.position = "absolute";
505
+ ghostEl.style.left = `${left}px`;
506
+ ghostEl.style.top = `${top}px`;
507
+ el.after(ghostEl);
508
+ return ghostEl;
509
+ }
510
+ setGhostElChildrenId(el) {
511
+ for (const child of Array.from(el.children)) {
512
+ if (child.id) {
513
+ child.id = `${GHOST_EL_ID_PREFIX}${child.id}`;
514
+ }
515
+ if (child.children.length) {
516
+ this.setGhostElChildrenId(child);
517
+ }
518
+ }
519
+ }
520
+ }
521
+
522
+ const selectParentAbles = (selectParentHandler) => ({
523
+ name: "select-parent",
524
+ props: {},
525
+ events: {},
526
+ render(moveable, React) {
527
+ const rect = moveable.getRect();
528
+ const { pos2 } = moveable.state;
529
+ const editableViewer = moveable.useCSS(
530
+ "div",
531
+ `
532
+ {
533
+ position: absolute;
534
+ left: 0px;
535
+ top: 0px;
536
+ will-change: transform;
537
+ transform-origin: 0px 0px;
538
+ display: flex;
539
+ }
540
+ .moveable-button {
541
+ width: 20px;
542
+ height: 20px;
543
+ background: #4af;
544
+ border-radius: 4px;
545
+ appearance: none;
546
+ border: 0;
547
+ color: white;
548
+ font-size: 12px;
549
+ font-weight: bold;
550
+ }
551
+ `
552
+ );
553
+ return React.createElement(
554
+ editableViewer,
555
+ {
556
+ className: "moveable-editable",
557
+ style: {
558
+ transform: `translate(${pos2[0] - 25}px, ${pos2[1] - 30}px) rotate(${rect.rotation}deg) translate(10px)`
559
+ }
560
+ },
561
+ React.createElement(
562
+ "button",
563
+ {
564
+ className: "moveable-button",
565
+ title: "\u9009\u4E2D\u7236\u7EC4\u4EF6",
566
+ onClick: () => {
567
+ selectParentHandler();
568
+ }
569
+ },
570
+ React.createElement(
571
+ "svg",
572
+ {
573
+ width: "1em",
574
+ height: "1em",
575
+ viewBox: "0 0 16 16",
576
+ fill: "none",
577
+ xmlns: "http://www.w3.org/2000/svg",
578
+ style: {
579
+ transform: "rotate(90deg)"
580
+ }
581
+ },
582
+ React.createElement("path", {
583
+ d: "M13.0001 4V10H4.20718L5.85363 8.35355L5.14652 7.64645L2.64652 10.1464C2.45126 10.3417 2.45126 10.6583 2.64652 10.8536L5.14652 13.3536L5.85363 12.6464L4.20718 11H13.0001C13.5524 11 14.0001 10.5523 14.0001 10V4H13.0001Z",
584
+ fill: "currentColor",
585
+ fillOpacity: "0.9"
586
+ })
587
+ )
588
+ )
589
+ );
590
+ }
591
+ });
592
+
593
+ class MoveableOptionsManager extends EventEmitter__default.default {
594
+ mode = Mode.ABSOLUTE;
595
+ container;
596
+ horizontalGuidelines = [];
597
+ verticalGuidelines = [];
598
+ elementGuidelines = [];
599
+ customizedOptions;
600
+ getRootContainer;
601
+ constructor(config) {
602
+ super();
603
+ this.customizedOptions = config.moveableOptions;
604
+ this.container = config.container;
605
+ this.getRootContainer = config.getRootContainer;
296
606
  }
297
607
  setGuidelines(type, guidelines) {
298
608
  if (type === GuidesType.HORIZONTAL) {
299
609
  this.horizontalGuidelines = guidelines;
300
- this.moveableOptions.horizontalGuidelines = guidelines;
301
610
  } else if (type === GuidesType.VERTICAL) {
302
611
  this.verticalGuidelines = guidelines;
303
- this.moveableOptions.verticalGuidelines = guidelines;
304
- }
305
- if (this.moveable) {
306
- this.updateMoveable();
307
612
  }
613
+ this.emit("update-moveable");
308
614
  }
309
615
  clearGuides() {
310
616
  this.horizontalGuidelines = [];
311
617
  this.verticalGuidelines = [];
312
- this.moveableOptions.horizontalGuidelines = [];
313
- this.moveableOptions.verticalGuidelines = [];
314
- this.updateMoveable();
315
- }
316
- clearSelectStatus() {
317
- if (!this.moveable)
318
- return;
319
- this.destroyDragEl();
320
- this.dragEl = void 0;
321
- this.moveable.target = null;
322
- this.moveable.updateTarget();
323
- }
324
- destroyDragEl() {
325
- this.dragEl?.remove();
326
- }
327
- destroy() {
328
- this.moveable?.destroy();
329
- this.destroyGhostEl();
330
- this.destroyDragEl();
331
- this.dragStatus = StageDragStatus.END;
332
- this.removeAllListeners();
333
- }
334
- init(el) {
335
- if (/(auto|scroll)/.test(el.style.overflow)) {
336
- el.style.overflow = "hidden";
337
- }
338
- this.mode = getMode(el);
339
- this.destroyGhostEl();
340
- if (!this.dragEl) {
341
- return;
342
- }
343
- this.dragEl.style.cssText = getTargetElStyle(el);
344
- this.dragEl.id = `${DRAG_EL_ID_PREFIX}${el.id}`;
345
- if (typeof this.core.config.updateDragEl === "function") {
346
- this.core.config.updateDragEl(this.dragEl, el);
347
- }
348
- this.moveableOptions = this.getOptions({
349
- target: this.dragEl
350
- });
618
+ this.emit("update-moveable");
351
619
  }
352
- setElementGuidelines(nodes) {
620
+ setElementGuidelines(selectedElList, allElList) {
353
621
  this.elementGuidelines.forEach((node) => {
354
622
  node.remove();
355
623
  });
356
624
  this.elementGuidelines = [];
357
625
  if (this.mode === Mode.ABSOLUTE) {
358
- this.container.append(this.createGuidelineElements(nodes));
626
+ this.container.append(this.createGuidelineElements(selectedElList, allElList));
627
+ }
628
+ }
629
+ getOptions(isMultiSelect, runtimeOptions = {}) {
630
+ const defaultOptions = this.getDefaultOptions(isMultiSelect);
631
+ const customizedOptions = this.getCustomizeOptions();
632
+ return lodashEs.merge(defaultOptions, customizedOptions, runtimeOptions);
633
+ }
634
+ getDefaultOptions(isMultiSelect) {
635
+ const isSortable = this.mode === Mode.SORTABLE;
636
+ const commonOptions = {
637
+ draggable: true,
638
+ resizable: true,
639
+ rootContainer: this.getRootContainer(),
640
+ zoom: 1,
641
+ throttleDrag: 0,
642
+ snappable: true,
643
+ horizontalGuidelines: this.horizontalGuidelines,
644
+ verticalGuidelines: this.verticalGuidelines,
645
+ elementGuidelines: this.elementGuidelines,
646
+ bounds: {
647
+ top: 0,
648
+ left: -1,
649
+ right: this.container.clientWidth - 1,
650
+ bottom: isSortable ? void 0 : this.container.clientHeight
651
+ }
652
+ };
653
+ const differenceOptions = isMultiSelect ? this.getMultiOptions() : this.getSingleOptions();
654
+ return lodashEs.merge(commonOptions, differenceOptions);
655
+ }
656
+ getSingleOptions() {
657
+ const isAbsolute = this.mode === Mode.ABSOLUTE;
658
+ const isFixed = this.mode === Mode.FIXED;
659
+ return {
660
+ origin: false,
661
+ dragArea: false,
662
+ scalable: false,
663
+ rotatable: false,
664
+ snapGap: isAbsolute || isFixed,
665
+ snapThreshold: 5,
666
+ snapDigit: 0,
667
+ isDisplaySnapDigit: isAbsolute,
668
+ snapDirections: {
669
+ top: isAbsolute,
670
+ right: isAbsolute,
671
+ bottom: isAbsolute,
672
+ left: isAbsolute,
673
+ center: isAbsolute,
674
+ middle: isAbsolute
675
+ },
676
+ elementSnapDirections: {
677
+ top: isAbsolute,
678
+ right: isAbsolute,
679
+ bottom: isAbsolute,
680
+ left: isAbsolute
681
+ },
682
+ isDisplayInnerSnapDigit: true,
683
+ props: {
684
+ selectParent: true
685
+ },
686
+ ables: [selectParentAbles(this.selectParentHandler.bind(this))]
687
+ };
688
+ }
689
+ getMultiOptions() {
690
+ return {
691
+ defaultGroupRotate: 0,
692
+ defaultGroupOrigin: "50% 50%",
693
+ startDragRotate: 0,
694
+ throttleDragRotate: 0,
695
+ origin: true,
696
+ padding: { left: 0, top: 0, right: 0, bottom: 0 }
697
+ };
698
+ }
699
+ getCustomizeOptions() {
700
+ if (typeof this.customizedOptions === "function") {
701
+ return this.customizedOptions();
359
702
  }
703
+ return this.customizedOptions;
704
+ }
705
+ selectParentHandler() {
706
+ this.emit("select-parent");
360
707
  }
361
- createGuidelineElements(nodes) {
708
+ createGuidelineElements(selectedElList, allElList) {
362
709
  const frame = globalThis.document.createDocumentFragment();
363
- for (const node of nodes) {
710
+ for (const node of allElList) {
364
711
  const { width, height } = node.getBoundingClientRect();
365
- if (node === this.target)
712
+ if (this.isInElementList(node, selectedElList))
366
713
  continue;
367
714
  const { left, top } = getOffset(node);
368
715
  const elementGuideline = globalThis.document.createElement("div");
@@ -372,10 +719,109 @@
372
719
  }
373
720
  return frame;
374
721
  }
375
- initMoveable() {
376
- this.moveable?.destroy();
377
- this.moveable = new Moveable__default.default(this.container, {
378
- ...this.moveableOptions
722
+ isInElementList(ele, eleList) {
723
+ for (const eleItem of eleList) {
724
+ if (ele === eleItem)
725
+ return true;
726
+ }
727
+ return false;
728
+ }
729
+ }
730
+
731
+ var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
732
+ ContainerHighlightType2["DEFAULT"] = "default";
733
+ ContainerHighlightType2["ALT"] = "alt";
734
+ return ContainerHighlightType2;
735
+ })(ContainerHighlightType || {});
736
+ var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
737
+ SelectStatus2["SELECT"] = "select";
738
+ SelectStatus2["MULTI_SELECT"] = "multiSelect";
739
+ return SelectStatus2;
740
+ })(SelectStatus || {});
741
+ var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
742
+ StageDragStatus2["START"] = "start";
743
+ StageDragStatus2["ING"] = "ing";
744
+ StageDragStatus2["END"] = "end";
745
+ return StageDragStatus2;
746
+ })(StageDragStatus || {});
747
+
748
+ class StageDragResize extends MoveableOptionsManager {
749
+ target;
750
+ moveable;
751
+ dragStatus = StageDragStatus.END;
752
+ dragResizeHelper;
753
+ getRenderDocument;
754
+ markContainerEnd;
755
+ delayedMarkContainer;
756
+ constructor(config) {
757
+ super(config);
758
+ this.getRenderDocument = config.getRenderDocument;
759
+ this.markContainerEnd = config.markContainerEnd;
760
+ this.delayedMarkContainer = config.delayedMarkContainer;
761
+ this.dragResizeHelper = new DragResizeHelper({
762
+ container: config.container,
763
+ updateDragEl: config.updateDragEl
764
+ });
765
+ this.on("update-moveable", () => {
766
+ if (this.moveable) {
767
+ this.updateMoveable();
768
+ }
769
+ });
770
+ }
771
+ select(el, event) {
772
+ if (!this.moveable || el !== this.target) {
773
+ this.initMoveable(el);
774
+ } else {
775
+ this.updateMoveable(el);
776
+ }
777
+ if (event) {
778
+ this.moveable?.dragStart(event);
779
+ }
780
+ }
781
+ updateMoveable(el = this.target) {
782
+ if (!this.moveable)
783
+ return;
784
+ if (!el)
785
+ throw new Error("\u672A\u9009\u4E2D\u4EFB\u4F55\u8282\u70B9");
786
+ const options = this.init(el);
787
+ Object.entries(options).forEach(([key, value]) => {
788
+ this.moveable[key] = value;
789
+ });
790
+ this.moveable.updateTarget();
791
+ }
792
+ clearSelectStatus() {
793
+ if (!this.moveable)
794
+ return;
795
+ this.dragResizeHelper.destroyShadowEl();
796
+ this.moveable.target = null;
797
+ this.moveable.updateTarget();
798
+ }
799
+ destroy() {
800
+ this.moveable?.destroy();
801
+ this.dragResizeHelper.destroy();
802
+ this.dragStatus = StageDragStatus.END;
803
+ this.removeAllListeners();
804
+ }
805
+ init(el) {
806
+ if (/(auto|scroll)/.test(el.style.overflow)) {
807
+ el.style.overflow = "hidden";
808
+ }
809
+ this.target = el;
810
+ this.mode = getMode(el);
811
+ this.dragResizeHelper.updateShadowEl(el);
812
+ this.dragResizeHelper.setMode(this.mode);
813
+ const elementGuidelines = Array.prototype.slice.call(this.target?.parentElement?.children) || [];
814
+ this.setElementGuidelines([this.target], elementGuidelines);
815
+ return this.getOptions(false, {
816
+ target: this.dragResizeHelper.getShadowEl()
817
+ });
818
+ }
819
+ initMoveable(el) {
820
+ const options = this.init(el);
821
+ this.dragResizeHelper.clear();
822
+ this.moveable?.destroy();
823
+ this.moveable = new Moveable__default.default(this.container, {
824
+ ...options
379
825
  });
380
826
  this.bindResizeEvent();
381
827
  this.bindDragEvent();
@@ -385,34 +831,16 @@
385
831
  bindResizeEvent() {
386
832
  if (!this.moveable)
387
833
  throw new Error("moveable \u672A\u521D\u59CB\u5316");
388
- const frame = {
389
- left: 0,
390
- top: 0
391
- };
392
834
  this.moveable.on("resizeStart", (e) => {
393
835
  if (!this.target)
394
836
  return;
395
837
  this.dragStatus = StageDragStatus.START;
396
- this.moveableHelper?.onResizeStart(e);
397
- frame.top = this.target.offsetTop;
398
- frame.left = this.target.offsetLeft;
838
+ this.dragResizeHelper.onResizeStart(e);
399
839
  }).on("resize", (e) => {
400
- const { width, height, drag } = e;
401
- if (!this.moveable || !this.target || !this.dragEl)
840
+ if (!this.moveable || !this.target || !this.dragResizeHelper.getShadowEl())
402
841
  return;
403
- const { beforeTranslate } = drag;
404
842
  this.dragStatus = StageDragStatus.ING;
405
- if (this.mode === Mode.SORTABLE) {
406
- this.target.style.top = "0px";
407
- this.dragEl.style.width = `${width}px`;
408
- this.dragEl.style.height = `${height}px`;
409
- } else {
410
- this.moveableHelper?.onResize(e);
411
- this.target.style.left = `${frame.left + beforeTranslate[0]}px`;
412
- this.target.style.top = `${frame.top + beforeTranslate[1]}px`;
413
- }
414
- this.target.style.width = `${width}px`;
415
- this.target.style.height = `${height}px`;
843
+ this.dragResizeHelper.onResize(e);
416
844
  }).on("resizeEnd", () => {
417
845
  this.dragStatus = StageDragStatus.END;
418
846
  this.update(true);
@@ -421,50 +849,28 @@
421
849
  bindDragEvent() {
422
850
  if (!this.moveable)
423
851
  throw new Error("moveable \u672A\u521D\u59CB\u5316");
424
- const frame = {
425
- left: 0,
426
- top: 0
427
- };
428
852
  let timeout;
429
- const { contentWindow } = this.core.renderer;
430
- const doc = contentWindow?.document;
431
853
  this.moveable.on("dragStart", (e) => {
432
854
  if (!this.target)
433
855
  throw new Error("\u672A\u9009\u4E2D\u7EC4\u4EF6");
434
856
  this.dragStatus = StageDragStatus.START;
435
- this.moveableHelper?.onDragStart(e);
436
- if (this.mode === Mode.SORTABLE) {
437
- this.ghostEl = this.generateGhostEl(this.target);
438
- }
439
- frame.top = this.target.offsetTop;
440
- frame.left = this.target.offsetLeft;
857
+ this.dragResizeHelper.onDragStart(e);
441
858
  }).on("drag", (e) => {
442
- if (!this.target || !this.dragEl)
859
+ if (!this.target || !this.dragResizeHelper.getShadowEl())
443
860
  return;
444
861
  if (timeout) {
445
862
  globalThis.clearTimeout(timeout);
446
863
  timeout = void 0;
447
864
  }
448
- if (this.canContainerHighlight()) {
449
- timeout = this.core.getAddContainerHighlightClassNameTimeout(e.inputEvent, [this.target]);
450
- }
865
+ timeout = this.delayedMarkContainer(e.inputEvent, [this.target]);
451
866
  this.dragStatus = StageDragStatus.ING;
452
- if (this.ghostEl) {
453
- this.ghostEl.style.top = `${frame.top + e.beforeTranslate[1]}px`;
454
- return;
455
- }
456
- this.moveableHelper?.onDrag(e);
457
- this.target.style.left = `${frame.left + e.beforeTranslate[0]}px`;
458
- this.target.style.top = `${frame.top + e.beforeTranslate[1]}px`;
867
+ this.dragResizeHelper.onDrag(e);
459
868
  }).on("dragEnd", () => {
460
869
  if (timeout) {
461
870
  globalThis.clearTimeout(timeout);
462
871
  timeout = void 0;
463
872
  }
464
- let parentEl = null;
465
- if (doc && this.canContainerHighlight()) {
466
- parentEl = utils.removeClassNameByClassName(doc, this.core.containerHighlightClassName);
467
- }
873
+ const parentEl = this.markContainerEnd();
468
874
  if (this.dragStatus === StageDragStatus.ING) {
469
875
  if (parentEl) {
470
876
  this.update(false, parentEl);
@@ -479,7 +885,7 @@
479
885
  }
480
886
  }
481
887
  this.dragStatus = StageDragStatus.END;
482
- this.destroyGhostEl();
888
+ this.dragResizeHelper.destroyGhostEl();
483
889
  });
484
890
  }
485
891
  bindRotateEvent() {
@@ -487,17 +893,15 @@
487
893
  throw new Error("moveable \u672A\u521D\u59CB\u5316");
488
894
  this.moveable.on("rotateStart", (e) => {
489
895
  this.dragStatus = StageDragStatus.START;
490
- this.moveableHelper?.onRotateStart(e);
896
+ this.dragResizeHelper.onRotateStart(e);
491
897
  }).on("rotate", (e) => {
492
- if (!this.target || !this.dragEl)
898
+ if (!this.target || !this.dragResizeHelper.getShadowEl())
493
899
  return;
494
900
  this.dragStatus = StageDragStatus.ING;
495
- this.moveableHelper?.onRotate(e);
496
- const frame = this.moveableHelper?.getFrame(e.target);
497
- this.target.style.transform = frame?.toCSSObject().transform || "";
901
+ this.dragResizeHelper.onRotate(e);
498
902
  }).on("rotateEnd", (e) => {
499
903
  this.dragStatus = StageDragStatus.END;
500
- const frame = this.moveableHelper?.getFrame(e.target);
904
+ const frame = this.dragResizeHelper?.getFrame(e.target);
501
905
  this.emit("update", {
502
906
  data: [
503
907
  {
@@ -515,17 +919,15 @@
515
919
  throw new Error("moveable \u672A\u521D\u59CB\u5316");
516
920
  this.moveable.on("scaleStart", (e) => {
517
921
  this.dragStatus = StageDragStatus.START;
518
- this.moveableHelper?.onScaleStart(e);
922
+ this.dragResizeHelper.onScaleStart(e);
519
923
  }).on("scale", (e) => {
520
- if (!this.target || !this.dragEl)
924
+ if (!this.target || !this.dragResizeHelper.getShadowEl())
521
925
  return;
522
926
  this.dragStatus = StageDragStatus.ING;
523
- this.moveableHelper?.onScale(e);
524
- const frame = this.moveableHelper?.getFrame(e.target);
525
- this.target.style.transform = frame?.toCSSObject().transform || "";
927
+ this.dragResizeHelper.onScale(e);
526
928
  }).on("scaleEnd", (e) => {
527
929
  this.dragStatus = StageDragStatus.END;
528
- const frame = this.moveableHelper?.getFrame(e.target);
930
+ const frame = this.dragResizeHelper.getFrame(e.target);
529
931
  this.emit("update", {
530
932
  data: [
531
933
  {
@@ -539,9 +941,9 @@
539
941
  });
540
942
  }
541
943
  sort() {
542
- if (!this.target || !this.ghostEl)
944
+ if (!this.target || !this.dragResizeHelper.getGhostEl())
543
945
  throw new Error("\u672A\u77E5\u9519\u8BEF");
544
- const { top } = this.ghostEl.getBoundingClientRect();
946
+ const { top } = this.dragResizeHelper.getGhostEl().getBoundingClientRect();
545
947
  const { top: oriTop } = this.target.getBoundingClientRect();
546
948
  const deltaTop = top - oriTop;
547
949
  if (Math.abs(deltaTop) >= this.target.clientHeight / 2) {
@@ -560,8 +962,7 @@
560
962
  update(isResize = false, parentEl = null) {
561
963
  if (!this.target)
562
964
  return;
563
- const { contentWindow } = this.core.renderer;
564
- const doc = contentWindow?.document;
965
+ const doc = this.getRenderDocument();
565
966
  if (!doc)
566
967
  return;
567
968
  const offset = this.mode === Mode.SORTABLE ? { left: 0, top: 0 } : { left: this.target.offsetLeft, top: this.target.offsetTop };
@@ -569,11 +970,16 @@
569
970
  let top = calcValueByFontsize(doc, offset.top);
570
971
  const width = calcValueByFontsize(doc, this.target.clientWidth);
571
972
  const height = calcValueByFontsize(doc, this.target.clientHeight);
572
- if (parentEl && this.mode === Mode.ABSOLUTE && this.dragEl) {
573
- const [translateX, translateY] = this.moveableHelper?.getFrame(this.dragEl).properties.transform.translate.value;
973
+ const shadowEl = this.dragResizeHelper.getShadowEl();
974
+ if (parentEl && this.mode === Mode.ABSOLUTE && shadowEl) {
975
+ const targetShadowHtmlEl = shadowEl;
976
+ const targetShadowElOffsetLeft = targetShadowHtmlEl.offsetLeft || 0;
977
+ const targetShadowElOffsetTop = targetShadowHtmlEl.offsetTop || 0;
978
+ const frame = this.dragResizeHelper.getFrame(shadowEl);
979
+ const [translateX, translateY] = frame?.properties.transform.translate.value;
574
980
  const { left: parentLeft, top: parentTop } = getOffset(parentEl);
575
- left = calcValueByFontsize(doc, this.dragEl.offsetLeft) + parseFloat(translateX) - calcValueByFontsize(doc, parentLeft);
576
- top = calcValueByFontsize(doc, this.dragEl.offsetTop) + parseFloat(translateY) - calcValueByFontsize(doc, parentTop);
981
+ left = calcValueByFontsize(doc, targetShadowElOffsetLeft) + parseFloat(translateX) - calcValueByFontsize(doc, parentLeft);
982
+ top = calcValueByFontsize(doc, targetShadowElOffsetTop) + parseFloat(translateY) - calcValueByFontsize(doc, parentTop);
577
983
  }
578
984
  this.emit("update", {
579
985
  data: [
@@ -585,187 +991,23 @@
585
991
  parentEl
586
992
  });
587
993
  }
588
- generateGhostEl(el) {
589
- if (this.ghostEl) {
590
- this.destroyGhostEl();
591
- }
592
- const ghostEl = el.cloneNode(true);
593
- this.setGhostElChildrenId(ghostEl);
594
- const { top, left } = getAbsolutePosition(el, getOffset(el));
595
- ghostEl.id = `${GHOST_EL_ID_PREFIX}${el.id}`;
596
- ghostEl.style.zIndex = ZIndex.GHOST_EL;
597
- ghostEl.style.opacity = ".5";
598
- ghostEl.style.position = "absolute";
599
- ghostEl.style.left = `${left}px`;
600
- ghostEl.style.top = `${top}px`;
601
- el.after(ghostEl);
602
- return ghostEl;
603
- }
604
- setGhostElChildrenId(el) {
605
- for (const child of Array.from(el.children)) {
606
- if (child.id) {
607
- child.id = `${GHOST_EL_ID_PREFIX}${child.id}`;
608
- }
609
- if (child.children.length) {
610
- this.setGhostElChildrenId(child);
611
- }
612
- }
613
- }
614
- destroyGhostEl() {
615
- this.ghostEl?.remove();
616
- this.ghostEl = void 0;
617
- }
618
- getOptions(options = {}) {
619
- if (!this.target)
620
- return {};
621
- const isAbsolute = this.mode === Mode.ABSOLUTE;
622
- const isFixed = this.mode === Mode.FIXED;
623
- const isSortable = this.mode === Mode.SORTABLE;
624
- let { moveableOptions = {} } = this.core.config;
625
- if (typeof moveableOptions === "function") {
626
- moveableOptions = moveableOptions(this.core);
627
- }
628
- const elementGuidelines = moveableOptions.elementGuidelines || this.target.parentElement?.children || [];
629
- this.setElementGuidelines(elementGuidelines);
630
- if (moveableOptions.elementGuidelines) {
631
- delete moveableOptions.elementGuidelines;
632
- }
633
- return {
634
- origin: false,
635
- rootContainer: this.core.container,
636
- zoom: 1,
637
- dragArea: false,
638
- draggable: true,
639
- resizable: true,
640
- scalable: false,
641
- rotatable: false,
642
- snappable: isAbsolute || isFixed,
643
- snapGap: isAbsolute || isFixed,
644
- snapThreshold: 5,
645
- snapDigit: 0,
646
- throttleDrag: 0,
647
- isDisplaySnapDigit: isAbsolute,
648
- snapDirections: {
649
- top: isAbsolute,
650
- right: isAbsolute,
651
- bottom: isAbsolute,
652
- left: isAbsolute,
653
- center: isAbsolute,
654
- middle: isAbsolute
655
- },
656
- elementSnapDirections: {
657
- top: isAbsolute,
658
- right: isAbsolute,
659
- bottom: isAbsolute,
660
- left: isAbsolute
661
- },
662
- isDisplayInnerSnapDigit: true,
663
- horizontalGuidelines: this.horizontalGuidelines,
664
- verticalGuidelines: this.verticalGuidelines,
665
- elementGuidelines: this.elementGuidelines,
666
- bounds: {
667
- top: 0,
668
- left: -1,
669
- right: this.container.clientWidth - 1,
670
- bottom: isSortable ? void 0 : this.container.clientHeight,
671
- ...moveableOptions.bounds || {}
672
- },
673
- ...options,
674
- ...moveableOptions
675
- };
676
- }
677
- canContainerHighlight() {
678
- return this.core.containerHighlightType === ContainerHighlightType.DEFAULT || this.core.containerHighlightType === ContainerHighlightType.ALT && this.isContainerHighlight;
679
- }
680
- }
681
-
682
- class TargetCalibrate extends EventEmitter.EventEmitter {
683
- parent;
684
- mask;
685
- dr;
686
- core;
687
- operationEl;
688
- constructor(config) {
689
- super();
690
- this.parent = config.parent;
691
- this.mask = config.mask;
692
- this.dr = config.dr;
693
- this.core = config.core;
694
- this.operationEl = globalThis.document.createElement("div");
695
- this.parent.append(this.operationEl);
696
- }
697
- update(el, prefix) {
698
- const { left, top } = this.getOffset(el);
699
- const { transform } = getComputedStyle(el);
700
- this.operationEl.style.cssText = `
701
- position: absolute;
702
- transform: ${transform};
703
- left: ${left}px;
704
- top: ${top}px;
705
- width: ${el.clientWidth}px;
706
- height: ${el.clientHeight}px;
707
- z-index: ${ZIndex.HIGHLIGHT_EL};
708
- `;
709
- this.operationEl.id = `${prefix}${el.id}`;
710
- if (typeof this.core.config.updateDragEl === "function") {
711
- this.core.config.updateDragEl(this.operationEl, el);
712
- }
713
- return this.operationEl;
714
- }
715
- destroy() {
716
- this.operationEl?.remove();
717
- }
718
- getOffset(el) {
719
- const { offsetParent } = el;
720
- const left = el.offsetLeft;
721
- const top = el.offsetTop;
722
- if (offsetParent) {
723
- const parentOffset = this.getOffset(offsetParent);
724
- return {
725
- left: left + parentOffset.left,
726
- top: top + parentOffset.top
727
- };
728
- }
729
- if (this.dr.mode === Mode.FIXED) {
730
- if (getMode(el) === Mode.FIXED) {
731
- return {
732
- left,
733
- top
734
- };
735
- }
736
- return {
737
- left: left - this.mask.scrollLeft,
738
- top: top - this.mask.scrollTop
739
- };
740
- }
741
- if (getMode(el) === Mode.FIXED) {
742
- return {
743
- left: left + this.mask.scrollLeft,
744
- top: top + this.mask.scrollTop
745
- };
746
- }
747
- return {
748
- left,
749
- top
750
- };
751
- }
752
994
  }
753
995
 
754
996
  class StageHighlight extends EventEmitter.EventEmitter {
755
- core;
756
997
  container;
757
998
  target;
758
999
  moveable;
759
- calibrationTarget;
1000
+ targetShadow;
1001
+ getRootContainer;
760
1002
  constructor(config) {
761
1003
  super();
762
- this.core = config.core;
763
1004
  this.container = config.container;
764
- this.calibrationTarget = new TargetCalibrate({
765
- parent: this.core.mask.content,
766
- mask: this.core.mask,
767
- dr: this.core.dr,
768
- core: this.core
1005
+ this.getRootContainer = config.getRootContainer;
1006
+ this.targetShadow = new TargetShadow({
1007
+ container: config.container,
1008
+ updateDragEl: config.updateDragEl,
1009
+ zIndex: ZIndex.HIGHLIGHT_EL,
1010
+ idPrefix: HIGHLIGHT_EL_ID_PREFIX
769
1011
  });
770
1012
  }
771
1013
  highlight(el) {
@@ -774,14 +1016,14 @@
774
1016
  this.target = el;
775
1017
  this.moveable?.destroy();
776
1018
  this.moveable = new Moveable__default.default(this.container, {
777
- target: this.calibrationTarget.update(el, HIGHLIGHT_EL_ID_PREFIX),
1019
+ target: this.targetShadow.update(el),
778
1020
  origin: false,
779
- rootContainer: this.core.container,
1021
+ rootContainer: this.getRootContainer(),
780
1022
  zoom: 2
781
1023
  });
782
1024
  }
783
1025
  clearHighlight() {
784
- if (!this.moveable)
1026
+ if (!this.moveable || !this.target)
785
1027
  return;
786
1028
  this.target = void 0;
787
1029
  this.moveable.target = null;
@@ -789,62 +1031,529 @@
789
1031
  }
790
1032
  destroy() {
791
1033
  this.moveable?.destroy();
792
- this.calibrationTarget.destroy();
1034
+ this.targetShadow.destroy();
793
1035
  }
794
1036
  }
795
1037
 
796
- class Rule extends EventEmitter__default.default {
797
- hGuides;
798
- vGuides;
799
- horizontalGuidelines = [];
800
- verticalGuidelines = [];
1038
+ class StageMultiDragResize extends MoveableOptionsManager {
801
1039
  container;
802
- containerResizeObserver;
803
- constructor(container) {
804
- super();
805
- this.container = container;
806
- this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
807
- this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
808
- this.hGuides.on("changeGuides", this.hGuidesChangeGuidesHandler);
809
- this.vGuides.on("changeGuides", this.vGuidesChangeGuidesHandler);
810
- this.containerResizeObserver = new ResizeObserver(() => {
811
- this.vGuides.resize();
812
- this.hGuides.resize();
813
- });
814
- this.containerResizeObserver.observe(this.container);
815
- }
816
- showGuides(show = true) {
817
- this.hGuides.setState({
818
- showGuides: show
1040
+ targetList = [];
1041
+ moveableForMulti;
1042
+ dragStatus = StageDragStatus.END;
1043
+ dragResizeHelper;
1044
+ getRenderDocument;
1045
+ constructor(config) {
1046
+ const moveableOptionsManagerConfig = {
1047
+ container: config.container,
1048
+ moveableOptions: config.multiMoveableOptions,
1049
+ getRootContainer: config.getRootContainer
1050
+ };
1051
+ super(moveableOptionsManagerConfig);
1052
+ this.container = config.container;
1053
+ this.getRenderDocument = config.getRenderDocument;
1054
+ this.dragResizeHelper = new DragResizeHelper({
1055
+ container: config.container,
1056
+ updateDragEl: config.updateDragEl
819
1057
  });
820
- this.vGuides.setState({
821
- showGuides: show
1058
+ this.on("update-moveable", () => {
1059
+ if (this.moveableForMulti) {
1060
+ this.updateMoveable();
1061
+ }
822
1062
  });
823
1063
  }
824
- setGuides([hLines, vLines]) {
825
- this.horizontalGuidelines = hLines;
826
- this.verticalGuidelines = vLines;
827
- this.hGuides.setState({
828
- defaultGuides: hLines
829
- });
830
- this.vGuides.setState({
831
- defaultGuides: vLines
1064
+ multiSelect(els) {
1065
+ if (els.length === 0) {
1066
+ return;
1067
+ }
1068
+ this.mode = getMode(els[0]);
1069
+ this.targetList = els;
1070
+ this.dragResizeHelper.updateGroup(els);
1071
+ const elementGuidelines = Array.prototype.slice.call(this.targetList[0].parentElement?.children) || [];
1072
+ this.setElementGuidelines(this.targetList, elementGuidelines);
1073
+ this.moveableForMulti?.destroy();
1074
+ this.dragResizeHelper.clear();
1075
+ this.moveableForMulti = new Moveable__default.default(
1076
+ this.container,
1077
+ this.getOptions(true, {
1078
+ target: this.dragResizeHelper.getShadowEls()
1079
+ })
1080
+ );
1081
+ this.moveableForMulti.on("resizeGroupStart", (e) => {
1082
+ this.dragResizeHelper.onResizeGroupStart(e);
1083
+ this.dragStatus = StageDragStatus.START;
1084
+ }).on("resizeGroup", (e) => {
1085
+ this.dragResizeHelper.onResizeGroup(e);
1086
+ this.dragStatus = StageDragStatus.ING;
1087
+ }).on("resizeGroupEnd", () => {
1088
+ this.update(true);
1089
+ this.dragStatus = StageDragStatus.END;
1090
+ }).on("dragGroupStart", (e) => {
1091
+ this.dragResizeHelper.onDragGroupStart(e);
1092
+ this.dragStatus = StageDragStatus.START;
1093
+ }).on("dragGroup", (e) => {
1094
+ this.dragResizeHelper.onDragGroup(e);
1095
+ this.dragStatus = StageDragStatus.ING;
1096
+ }).on("dragGroupEnd", () => {
1097
+ this.update();
1098
+ this.dragStatus = StageDragStatus.END;
1099
+ }).on("clickGroup", (e) => {
1100
+ const { inputTarget, targets } = e;
1101
+ if (targets.length > 1 && targets.includes(inputTarget)) {
1102
+ this.emit("change-to-select", inputTarget.id.replace(DRAG_EL_ID_PREFIX, ""));
1103
+ }
832
1104
  });
833
- this.emit("changeGuides", {
834
- type: GuidesType.HORIZONTAL,
835
- guides: hLines
1105
+ }
1106
+ canSelect(el, selectedEl) {
1107
+ const currentTargetMode = getMode(el);
1108
+ let selectedElMode = "";
1109
+ if (currentTargetMode === Mode.SORTABLE) {
1110
+ return false;
1111
+ }
1112
+ if (this.targetList.length === 0 && selectedEl) {
1113
+ selectedElMode = getMode(selectedEl);
1114
+ } else if (this.targetList.length > 0) {
1115
+ selectedElMode = getMode(this.targetList[0]);
1116
+ }
1117
+ if (currentTargetMode !== selectedElMode) {
1118
+ return false;
1119
+ }
1120
+ return true;
1121
+ }
1122
+ updateMoveable(eleList = this.targetList) {
1123
+ if (!this.moveableForMulti)
1124
+ return;
1125
+ if (!eleList)
1126
+ throw new Error("\u672A\u9009\u4E2D\u4EFB\u4F55\u8282\u70B9");
1127
+ this.targetList = eleList;
1128
+ this.dragResizeHelper.setTargetList(eleList);
1129
+ const options = this.getOptions(true, {
1130
+ target: this.dragResizeHelper.getShadowEls()
836
1131
  });
837
- this.emit("changeGuides", {
838
- type: GuidesType.VERTICAL,
839
- guides: vLines
1132
+ Object.entries(options).forEach(([key, value]) => {
1133
+ this.moveableForMulti[key] = value;
840
1134
  });
1135
+ this.moveableForMulti.updateTarget();
841
1136
  }
842
- clearGuides() {
843
- this.setGuides([[], []]);
1137
+ clearSelectStatus() {
1138
+ if (!this.moveableForMulti)
1139
+ return;
1140
+ this.dragResizeHelper.clearMultiSelectStatus();
1141
+ this.moveableForMulti.target = null;
1142
+ this.moveableForMulti.updateTarget();
1143
+ this.targetList = [];
844
1144
  }
845
- showRule(show = true) {
846
- if (show) {
847
- this.hGuides.destroy();
1145
+ destroy() {
1146
+ this.moveableForMulti?.destroy();
1147
+ this.dragResizeHelper.destroy();
1148
+ }
1149
+ update(isResize = false) {
1150
+ if (this.targetList.length === 0)
1151
+ return;
1152
+ const doc = this.getRenderDocument();
1153
+ if (!doc)
1154
+ return;
1155
+ const data = this.targetList.map((targetItem) => {
1156
+ const left = calcValueByFontsize(doc, targetItem.offsetLeft);
1157
+ const top = calcValueByFontsize(doc, targetItem.offsetTop);
1158
+ const width = calcValueByFontsize(doc, targetItem.clientWidth);
1159
+ const height = calcValueByFontsize(doc, targetItem.clientHeight);
1160
+ return {
1161
+ el: targetItem,
1162
+ style: isResize ? { left, top, width, height } : { left, top }
1163
+ };
1164
+ });
1165
+ this.emit("update", data, null);
1166
+ }
1167
+ }
1168
+
1169
+ const throttleTime = 100;
1170
+ const defaultContainerHighlightDuration = 800;
1171
+ class ActionManager extends EventEmitter__default.default {
1172
+ dr;
1173
+ multiDr;
1174
+ highlightLayer;
1175
+ container;
1176
+ selectedEl;
1177
+ selectedElList = [];
1178
+ highlightedEl;
1179
+ isMultiSelectStatus = false;
1180
+ containerHighlightClassName;
1181
+ containerHighlightDuration;
1182
+ containerHighlightType;
1183
+ isAltKeydown = false;
1184
+ getTargetElement;
1185
+ getElementsFromPoint;
1186
+ canSelect;
1187
+ isContainer;
1188
+ getRenderDocument;
1189
+ mouseMoveHandler = lodashEs.throttle(async (event) => {
1190
+ const el = await this.getElementFromPoint(event);
1191
+ if (!el) {
1192
+ this.clearHighlight();
1193
+ return;
1194
+ }
1195
+ this.highlight(el);
1196
+ }, throttleTime);
1197
+ constructor(config) {
1198
+ super();
1199
+ this.container = config.container;
1200
+ this.containerHighlightClassName = config.containerHighlightClassName || CONTAINER_HIGHLIGHT_CLASS_NAME;
1201
+ this.containerHighlightDuration = config.containerHighlightDuration || defaultContainerHighlightDuration;
1202
+ this.containerHighlightType = config.containerHighlightType;
1203
+ this.getTargetElement = config.getTargetElement;
1204
+ this.getElementsFromPoint = config.getElementsFromPoint;
1205
+ this.canSelect = config.canSelect || ((el) => !!el.id);
1206
+ this.getRenderDocument = config.getRenderDocument;
1207
+ this.isContainer = config.isContainer;
1208
+ this.dr = new StageDragResize({
1209
+ container: config.container,
1210
+ getRootContainer: config.getRootContainer,
1211
+ getRenderDocument: config.getRenderDocument,
1212
+ updateDragEl: config.updateDragEl,
1213
+ markContainerEnd: () => this.markContainerEnd(),
1214
+ delayedMarkContainer: (event, exclude) => {
1215
+ if (this.canAddToContainer()) {
1216
+ return this.delayedMarkContainer(event, exclude);
1217
+ }
1218
+ return void 0;
1219
+ },
1220
+ moveableOptions: this.changeCallback(config.moveableOptions)
1221
+ });
1222
+ this.multiDr = new StageMultiDragResize({
1223
+ container: config.container,
1224
+ multiMoveableOptions: config.multiMoveableOptions,
1225
+ getRootContainer: config.getRootContainer,
1226
+ getRenderDocument: config.getRenderDocument,
1227
+ updateDragEl: config.updateDragEl
1228
+ });
1229
+ this.highlightLayer = new StageHighlight({
1230
+ container: config.container,
1231
+ updateDragEl: config.updateDragEl,
1232
+ getRootContainer: config.getRootContainer
1233
+ });
1234
+ this.initMouseEvent();
1235
+ this.initKeyEvent();
1236
+ this.initActionEvent();
1237
+ }
1238
+ setGuidelines(type, guidelines) {
1239
+ this.dr.setGuidelines(type, guidelines);
1240
+ this.multiDr.setGuidelines(type, guidelines);
1241
+ }
1242
+ clearGuides() {
1243
+ this.dr.clearGuides();
1244
+ this.multiDr.clearGuides();
1245
+ }
1246
+ updateMoveable(el) {
1247
+ this.dr.updateMoveable(el);
1248
+ this.multiDr.updateMoveable();
1249
+ }
1250
+ isSelectedEl(el) {
1251
+ return el.id === this.selectedEl?.id;
1252
+ }
1253
+ setSelectedEl(el) {
1254
+ this.selectedEl = el;
1255
+ }
1256
+ getSelectedEl() {
1257
+ return this.selectedEl;
1258
+ }
1259
+ getSelectedElList() {
1260
+ return this.selectedElList;
1261
+ }
1262
+ async getElementFromPoint(event) {
1263
+ const els = this.getElementsFromPoint(event);
1264
+ let stopped = false;
1265
+ const stop = () => stopped = true;
1266
+ for (const el of els) {
1267
+ if (!el.id.startsWith(GHOST_EL_ID_PREFIX) && await this.isElCanSelect(el, event, stop)) {
1268
+ if (stopped)
1269
+ break;
1270
+ return el;
1271
+ }
1272
+ }
1273
+ }
1274
+ async isElCanSelect(el, event, stop) {
1275
+ const canSelectByProp = await this.canSelect(el, event, stop);
1276
+ if (!canSelectByProp)
1277
+ return false;
1278
+ if (this.isMultiSelectStatus) {
1279
+ return this.canMultiSelect(el, stop);
1280
+ }
1281
+ return true;
1282
+ }
1283
+ canMultiSelect(el, stop) {
1284
+ if (el.className.includes(PAGE_CLASS)) {
1285
+ stop();
1286
+ return false;
1287
+ }
1288
+ const selectedEl = this.getSelectedEl();
1289
+ if (selectedEl?.className.includes(PAGE_CLASS)) {
1290
+ return true;
1291
+ }
1292
+ return this.multiDr.canSelect(el, selectedEl);
1293
+ }
1294
+ select(el, event) {
1295
+ this.selectedEl = el;
1296
+ this.clearSelectStatus(SelectStatus.MULTI_SELECT);
1297
+ this.dr.select(el, event);
1298
+ }
1299
+ multiSelect(idOrElList) {
1300
+ this.selectedElList = idOrElList.map((idOrEl) => this.getTargetElement(idOrEl));
1301
+ this.clearSelectStatus(SelectStatus.SELECT);
1302
+ this.multiDr.multiSelect(this.selectedElList);
1303
+ }
1304
+ getHighlightEl() {
1305
+ return this.highlightedEl;
1306
+ }
1307
+ setHighlightEl(el) {
1308
+ this.highlightedEl = el;
1309
+ }
1310
+ highlight(idOrEl) {
1311
+ let el;
1312
+ try {
1313
+ el = this.getTargetElement(idOrEl);
1314
+ } catch (error) {
1315
+ this.clearHighlight();
1316
+ return;
1317
+ }
1318
+ if (el === this.getSelectedEl() || this.multiDr.dragStatus === StageDragStatus.ING) {
1319
+ this.clearHighlight();
1320
+ return;
1321
+ }
1322
+ if (el === this.highlightedEl || !el)
1323
+ return;
1324
+ this.highlightLayer.highlight(el);
1325
+ this.highlightedEl = el;
1326
+ this.emit("highlight", el);
1327
+ }
1328
+ clearHighlight() {
1329
+ this.setHighlightEl(void 0);
1330
+ this.highlightLayer.clearHighlight();
1331
+ }
1332
+ clearSelectStatus(selectType) {
1333
+ if (selectType === SelectStatus.MULTI_SELECT) {
1334
+ this.multiDr.clearSelectStatus();
1335
+ this.selectedElList = [];
1336
+ } else {
1337
+ this.dr.clearSelectStatus();
1338
+ }
1339
+ }
1340
+ async addContainerHighlightClassName(event, excludeElList) {
1341
+ const doc = this.getRenderDocument();
1342
+ if (!doc)
1343
+ return;
1344
+ const els = this.getElementsFromPoint(event);
1345
+ for (const el of els) {
1346
+ if (!el.id.startsWith(GHOST_EL_ID_PREFIX) && await this.isContainer(el) && !excludeElList.includes(el)) {
1347
+ utils.addClassName(el, doc, this.containerHighlightClassName);
1348
+ break;
1349
+ }
1350
+ }
1351
+ }
1352
+ delayedMarkContainer(event, excludeElList = []) {
1353
+ return globalThis.setTimeout(() => {
1354
+ this.addContainerHighlightClassName(event, excludeElList);
1355
+ }, this.containerHighlightDuration);
1356
+ }
1357
+ destroy() {
1358
+ this.container.removeEventListener("mousedown", this.mouseDownHandler);
1359
+ this.container.removeEventListener("mousemove", this.mouseMoveHandler);
1360
+ this.container.removeEventListener("mouseleave", this.mouseLeaveHandler);
1361
+ this.container.removeEventListener("wheel", this.mouseWheelHandler);
1362
+ this.dr.destroy();
1363
+ this.multiDr.destroy();
1364
+ this.highlightLayer.destroy();
1365
+ }
1366
+ changeCallback(options) {
1367
+ if (typeof options === "function") {
1368
+ return () => {
1369
+ if (typeof options === "function") {
1370
+ const cfg = {
1371
+ targetElId: this.selectedEl?.id
1372
+ };
1373
+ return options(cfg);
1374
+ }
1375
+ return options;
1376
+ };
1377
+ }
1378
+ return options;
1379
+ }
1380
+ async beforeMultiSelect(event) {
1381
+ const el = await this.getElementFromPoint(event);
1382
+ if (!el)
1383
+ return;
1384
+ if (this.selectedEl && !this.selectedEl.className.includes(PAGE_CLASS)) {
1385
+ this.selectedElList.push(this.selectedEl);
1386
+ this.selectedEl = void 0;
1387
+ }
1388
+ const existIndex = this.selectedElList.findIndex((selectedDom) => selectedDom.id === el.id);
1389
+ if (existIndex !== -1) {
1390
+ this.selectedElList.splice(existIndex, 1);
1391
+ } else {
1392
+ this.selectedElList.push(el);
1393
+ }
1394
+ }
1395
+ canAddToContainer() {
1396
+ return this.containerHighlightType === ContainerHighlightType.DEFAULT || this.containerHighlightType === ContainerHighlightType.ALT && this.isAltKeydown;
1397
+ }
1398
+ markContainerEnd() {
1399
+ const doc = this.getRenderDocument();
1400
+ if (doc && this.canAddToContainer()) {
1401
+ return utils.removeClassNameByClassName(doc, this.containerHighlightClassName);
1402
+ }
1403
+ return null;
1404
+ }
1405
+ initMouseEvent() {
1406
+ this.container.addEventListener("mousedown", this.mouseDownHandler);
1407
+ this.container.addEventListener("mousemove", this.mouseMoveHandler);
1408
+ this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
1409
+ this.container.addEventListener("wheel", this.mouseWheelHandler);
1410
+ }
1411
+ initKeyEvent() {
1412
+ const { isMac } = new core.Env();
1413
+ const ctrl = isMac ? "meta" : "ctrl";
1414
+ KeyController__default.default.global.keydown(ctrl, (e) => {
1415
+ e.inputEvent.preventDefault();
1416
+ this.isMultiSelectStatus = true;
1417
+ });
1418
+ KeyController__default.default.global.on("blur", () => {
1419
+ this.isMultiSelectStatus = false;
1420
+ });
1421
+ KeyController__default.default.global.keyup(ctrl, (e) => {
1422
+ e.inputEvent.preventDefault();
1423
+ this.isMultiSelectStatus = false;
1424
+ });
1425
+ KeyController__default.default.global.keydown("alt", (e) => {
1426
+ e.inputEvent.preventDefault();
1427
+ this.isAltKeydown = true;
1428
+ });
1429
+ KeyController__default.default.global.keyup("alt", (e) => {
1430
+ e.inputEvent.preventDefault();
1431
+ this.markContainerEnd();
1432
+ this.isAltKeydown = false;
1433
+ });
1434
+ }
1435
+ initActionEvent() {
1436
+ this.dr.on("update", (data) => {
1437
+ setTimeout(() => this.emit("update", data));
1438
+ }).on("sort", (data) => {
1439
+ setTimeout(() => this.emit("sort", data));
1440
+ }).on("select-parent", () => {
1441
+ this.emit("select-parent");
1442
+ });
1443
+ this.multiDr.on("update", (data, parentEl) => {
1444
+ this.emit("multi-update", data, parentEl);
1445
+ }).on("change-to-select", async (id) => {
1446
+ if (this.isMultiSelectStatus)
1447
+ return false;
1448
+ const el = this.getTargetElement(id);
1449
+ this.emit("change-to-select", el);
1450
+ });
1451
+ }
1452
+ mouseDownHandler = async (event) => {
1453
+ this.clearHighlight();
1454
+ event.stopImmediatePropagation();
1455
+ event.stopPropagation();
1456
+ if (this.isStopTriggerSelect(event))
1457
+ return;
1458
+ this.container.removeEventListener("mousemove", this.mouseMoveHandler);
1459
+ if (this.isMultiSelectStatus) {
1460
+ await this.beforeMultiSelect(event);
1461
+ if (this.selectedElList.length > 0) {
1462
+ this.emit("before-multi-select", this.selectedElList);
1463
+ }
1464
+ } else {
1465
+ const el = await this.getElementFromPoint(event);
1466
+ if (!el)
1467
+ return;
1468
+ this.emit("before-select", el, event);
1469
+ }
1470
+ utils.getDocument().addEventListener("mouseup", this.mouseUpHandler);
1471
+ };
1472
+ isStopTriggerSelect(event) {
1473
+ if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT)
1474
+ return true;
1475
+ if (!event.target)
1476
+ return true;
1477
+ const targetClassList = event.target.classList;
1478
+ if (!this.isMultiSelectStatus && targetClassList.contains("moveable-area")) {
1479
+ return true;
1480
+ }
1481
+ if (targetClassList.contains("moveable-control") || isMoveableButton(event.target)) {
1482
+ return true;
1483
+ }
1484
+ return false;
1485
+ }
1486
+ mouseUpHandler = () => {
1487
+ utils.getDocument().removeEventListener("mouseup", this.mouseUpHandler);
1488
+ this.container.addEventListener("mousemove", this.mouseMoveHandler);
1489
+ if (this.isMultiSelectStatus) {
1490
+ this.emit("multi-select", this.selectedElList);
1491
+ } else {
1492
+ this.emit("select", this.selectedEl);
1493
+ }
1494
+ };
1495
+ mouseLeaveHandler = () => {
1496
+ setTimeout(() => this.clearHighlight(), throttleTime);
1497
+ };
1498
+ mouseWheelHandler = () => {
1499
+ this.clearHighlight();
1500
+ };
1501
+ }
1502
+
1503
+ class Rule extends EventEmitter__default.default {
1504
+ hGuides;
1505
+ vGuides;
1506
+ horizontalGuidelines = [];
1507
+ verticalGuidelines = [];
1508
+ container;
1509
+ containerResizeObserver;
1510
+ isShowGuides = true;
1511
+ constructor(container) {
1512
+ super();
1513
+ this.container = container;
1514
+ this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
1515
+ this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
1516
+ this.hGuides.on("changeGuides", this.hGuidesChangeGuidesHandler);
1517
+ this.vGuides.on("changeGuides", this.vGuidesChangeGuidesHandler);
1518
+ this.containerResizeObserver = new ResizeObserver(() => {
1519
+ this.vGuides.resize();
1520
+ this.hGuides.resize();
1521
+ });
1522
+ this.containerResizeObserver.observe(this.container);
1523
+ }
1524
+ showGuides(isShowGuides = true) {
1525
+ this.isShowGuides = isShowGuides;
1526
+ this.hGuides.setState({
1527
+ showGuides: isShowGuides
1528
+ });
1529
+ this.vGuides.setState({
1530
+ showGuides: isShowGuides
1531
+ });
1532
+ }
1533
+ setGuides([hLines, vLines]) {
1534
+ this.horizontalGuidelines = hLines;
1535
+ this.verticalGuidelines = vLines;
1536
+ this.hGuides.setState({
1537
+ defaultGuides: hLines
1538
+ });
1539
+ this.vGuides.setState({
1540
+ defaultGuides: vLines
1541
+ });
1542
+ this.emit("change-guides", {
1543
+ type: GuidesType.HORIZONTAL,
1544
+ guides: hLines
1545
+ });
1546
+ this.emit("change-guides", {
1547
+ type: GuidesType.VERTICAL,
1548
+ guides: vLines
1549
+ });
1550
+ }
1551
+ clearGuides() {
1552
+ this.setGuides([[], []]);
1553
+ }
1554
+ showRule(show = true) {
1555
+ if (show) {
1556
+ this.hGuides.destroy();
848
1557
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
849
1558
  this.vGuides.destroy();
850
1559
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
@@ -888,18 +1597,19 @@
888
1597
  backgroundColor: "#fff",
889
1598
  lineColor: "#000",
890
1599
  textColor: "#000",
891
- style: this.getGuidesStyle(type)
1600
+ style: this.getGuidesStyle(type),
1601
+ showGuides: this.isShowGuides
892
1602
  });
893
1603
  hGuidesChangeGuidesHandler = (e) => {
894
1604
  this.horizontalGuidelines = e.guides;
895
- this.emit("changeGuides", {
1605
+ this.emit("change-guides", {
896
1606
  type: GuidesType.HORIZONTAL,
897
1607
  guides: this.horizontalGuidelines
898
1608
  });
899
1609
  };
900
1610
  vGuidesChangeGuidesHandler = (e) => {
901
1611
  this.verticalGuidelines = e.guides;
902
- this.emit("changeGuides", {
1612
+ this.emit("change-guides", {
903
1613
  type: GuidesType.VERTICAL,
904
1614
  guides: this.verticalGuidelines
905
1615
  });
@@ -907,9 +1617,8 @@
907
1617
  }
908
1618
 
909
1619
  const wrapperClassName = "editor-mask-wrapper";
910
- const throttleTime = 100;
911
1620
  const hideScrollbar = () => {
912
- utils.injectStyle(globalThis.document, `.${wrapperClassName}::-webkit-scrollbar { width: 0 !important; display: none }`);
1621
+ utils.injectStyle(utils.getDocument(), `.${wrapperClassName}::-webkit-scrollbar { width: 0 !important; display: none }`);
913
1622
  };
914
1623
  const createContent = () => utils.createDiv({
915
1624
  className: "editor-mask",
@@ -939,9 +1648,7 @@
939
1648
  class StageMask extends Rule {
940
1649
  content = createContent();
941
1650
  wrapper;
942
- core;
943
1651
  page = null;
944
- pageScrollParent = null;
945
1652
  scrollTop = 0;
946
1653
  scrollLeft = 0;
947
1654
  width = 0;
@@ -950,41 +1657,21 @@
950
1657
  wrapperWidth = 0;
951
1658
  maxScrollTop = 0;
952
1659
  maxScrollLeft = 0;
953
- intersectionObserver = null;
954
- isMultiSelectStatus = false;
955
1660
  mode = Mode.ABSOLUTE;
956
- pageResizeObserver = null;
1661
+ pageScrollParent = null;
1662
+ intersectionObserver = null;
957
1663
  wrapperResizeObserver = null;
958
- highlightHandler = lodashEs.throttle((event) => {
959
- this.emit("highlight", event);
960
- }, throttleTime);
961
- constructor(config) {
1664
+ constructor() {
962
1665
  const wrapper = createWrapper();
963
1666
  super(wrapper);
964
1667
  this.wrapper = wrapper;
965
- this.core = config.core;
966
- this.content.addEventListener("mousedown", this.mouseDownHandler);
967
- this.wrapper.appendChild(this.content);
968
1668
  this.content.addEventListener("wheel", this.mouseWheelHandler);
969
- this.content.addEventListener("mousemove", this.highlightHandler);
970
- this.content.addEventListener("mouseleave", this.mouseLeaveHandler);
971
- const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
972
- const ctrl = isMac ? "meta" : "ctrl";
973
- KeyController__default.default.global.keydown(ctrl, (e) => {
974
- e.inputEvent.preventDefault();
975
- this.isMultiSelectStatus = true;
976
- });
977
- KeyController__default.default.global.on("blur", () => {
978
- this.isMultiSelectStatus = false;
979
- });
980
- KeyController__default.default.global.keyup(ctrl, (e) => {
981
- e.inputEvent.preventDefault();
982
- this.isMultiSelectStatus = false;
983
- });
1669
+ this.wrapper.appendChild(this.content);
984
1670
  }
985
1671
  setMode(mode) {
986
1672
  this.mode = mode;
987
1673
  this.scroll();
1674
+ this.content.dataset.mode = mode;
988
1675
  if (mode === Mode.FIXED) {
989
1676
  this.content.style.width = `${this.wrapperWidth}px`;
990
1677
  this.content.style.height = `${this.wrapperHeight}px`;
@@ -997,9 +1684,44 @@
997
1684
  if (!page)
998
1685
  return;
999
1686
  this.page = page;
1000
- this.pageScrollParent = getScrollParent(page) || this.core.renderer.contentWindow?.document.documentElement || null;
1001
- this.pageResizeObserver?.disconnect();
1687
+ this.initObserverIntersection();
1688
+ this.initObserverWrapper();
1689
+ }
1690
+ pageResize(entries) {
1691
+ const [entry] = entries;
1692
+ const { clientHeight, clientWidth } = entry.target;
1693
+ this.setHeight(clientHeight);
1694
+ this.setWidth(clientWidth);
1695
+ this.scroll();
1696
+ }
1697
+ observerIntersection(el) {
1698
+ this.intersectionObserver?.observe(el);
1699
+ }
1700
+ mount(el) {
1701
+ if (!this.content)
1702
+ throw new Error("content \u4E0D\u5B58\u5728");
1703
+ el.appendChild(this.wrapper);
1704
+ }
1705
+ setLayout(el) {
1706
+ this.setMode(isFixedParent(el) ? Mode.FIXED : Mode.ABSOLUTE);
1707
+ }
1708
+ scrollIntoView(el) {
1709
+ el.scrollIntoView();
1710
+ if (!this.pageScrollParent)
1711
+ return;
1712
+ this.scrollLeft = this.pageScrollParent.scrollLeft;
1713
+ this.scrollTop = this.pageScrollParent.scrollTop;
1714
+ this.scroll();
1715
+ }
1716
+ destroy() {
1717
+ this.content?.remove();
1718
+ this.page = null;
1719
+ this.pageScrollParent = null;
1002
1720
  this.wrapperResizeObserver?.disconnect();
1721
+ super.destroy();
1722
+ }
1723
+ initObserverIntersection() {
1724
+ this.pageScrollParent = getScrollParent(this.page) || null;
1003
1725
  this.intersectionObserver?.disconnect();
1004
1726
  if (typeof IntersectionObserver !== "undefined") {
1005
1727
  this.intersectionObserver = new IntersectionObserver(
@@ -1019,18 +1741,10 @@
1019
1741
  }
1020
1742
  );
1021
1743
  }
1744
+ }
1745
+ initObserverWrapper() {
1746
+ this.wrapperResizeObserver?.disconnect();
1022
1747
  if (typeof ResizeObserver !== "undefined") {
1023
- this.pageResizeObserver = new ResizeObserver((entries) => {
1024
- const [entry] = entries;
1025
- const { clientHeight, clientWidth } = entry.target;
1026
- this.setHeight(clientHeight);
1027
- this.setWidth(clientWidth);
1028
- this.scroll();
1029
- if (this.core.dr.moveable) {
1030
- this.core.dr.updateMoveable();
1031
- }
1032
- });
1033
- this.pageResizeObserver.observe(page);
1034
1748
  this.wrapperResizeObserver = new ResizeObserver((entries) => {
1035
1749
  const [entry] = entries;
1036
1750
  const { clientHeight, clientWidth } = entry.target;
@@ -1042,338 +1756,75 @@
1042
1756
  this.wrapperResizeObserver.observe(this.wrapper);
1043
1757
  }
1044
1758
  }
1045
- mount(el) {
1046
- if (!this.content)
1047
- throw new Error("content \u4E0D\u5B58\u5728");
1048
- el.appendChild(this.wrapper);
1049
- }
1050
- setLayout(el) {
1051
- this.setMode(isFixedParent(el) ? Mode.FIXED : Mode.ABSOLUTE);
1052
- }
1053
- scrollIntoView(el) {
1054
- el.scrollIntoView();
1055
- if (!this.pageScrollParent)
1056
- return;
1057
- this.scrollLeft = this.pageScrollParent.scrollLeft;
1058
- this.scrollTop = this.pageScrollParent.scrollTop;
1059
- this.scroll();
1060
- }
1061
- destroy() {
1062
- this.content?.remove();
1063
- this.page = null;
1064
- this.pageScrollParent = null;
1065
- this.pageResizeObserver?.disconnect();
1066
- this.wrapperResizeObserver?.disconnect();
1067
- this.content.removeEventListener("mouseleave", this.mouseLeaveHandler);
1068
- super.destroy();
1069
- }
1070
1759
  scroll() {
1071
1760
  this.fixScrollValue();
1072
1761
  let { scrollLeft, scrollTop } = this;
1073
1762
  if (this.pageScrollParent) {
1074
1763
  this.pageScrollParent.scrollTo({
1075
1764
  top: scrollTop,
1076
- left: scrollLeft
1077
- });
1078
- }
1079
- if (this.mode === Mode.FIXED) {
1080
- scrollLeft = 0;
1081
- scrollTop = 0;
1082
- }
1083
- this.scrollRule(scrollTop);
1084
- this.scrollTo(scrollLeft, scrollTop);
1085
- }
1086
- scrollTo(scrollLeft, scrollTop) {
1087
- this.content.style.transform = `translate3d(${-scrollLeft}px, ${-scrollTop}px, 0)`;
1088
- }
1089
- setHeight(height) {
1090
- this.height = height;
1091
- this.setMaxScrollTop();
1092
- this.content.style.height = `${height}px`;
1093
- }
1094
- setWidth(width) {
1095
- this.width = width;
1096
- this.setMaxScrollLeft();
1097
- this.content.style.width = `${width}px`;
1098
- }
1099
- setMaxScrollLeft() {
1100
- this.maxScrollLeft = Math.max(this.width - this.wrapperWidth, 0);
1101
- }
1102
- setMaxScrollTop() {
1103
- this.maxScrollTop = Math.max(this.height - this.wrapperHeight, 0);
1104
- }
1105
- fixScrollValue() {
1106
- if (this.scrollTop < 0)
1107
- this.scrollTop = 0;
1108
- if (this.scrollLeft < 0)
1109
- this.scrollLeft = 0;
1110
- if (this.maxScrollTop < this.scrollTop)
1111
- this.scrollTop = this.maxScrollTop;
1112
- if (this.maxScrollLeft < this.scrollLeft)
1113
- this.scrollLeft = this.maxScrollLeft;
1114
- }
1115
- mouseDownHandler = (event) => {
1116
- this.emit("clearHighlight");
1117
- event.stopImmediatePropagation();
1118
- event.stopPropagation();
1119
- if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT)
1120
- return;
1121
- if (!this.isMultiSelectStatus && event.target.className.indexOf("moveable-area") !== -1) {
1122
- return;
1123
- }
1124
- if (event.target.className.indexOf("moveable-control") !== -1) {
1125
- return;
1126
- }
1127
- this.content.removeEventListener("mousemove", this.highlightHandler);
1128
- if (this.isMultiSelectStatus) {
1129
- this.emit("beforeMultiSelect", event);
1130
- } else {
1131
- this.emit("beforeSelect", event);
1132
- }
1133
- globalThis.document.addEventListener("mouseup", this.mouseUpHandler);
1134
- };
1135
- mouseUpHandler = () => {
1136
- globalThis.document.removeEventListener("mouseup", this.mouseUpHandler);
1137
- this.content.addEventListener("mousemove", this.highlightHandler);
1138
- if (!this.isMultiSelectStatus) {
1139
- this.emit("select");
1140
- }
1141
- };
1142
- mouseWheelHandler = (event) => {
1143
- this.emit("clearHighlight");
1144
- if (!this.page)
1145
- throw new Error("page \u672A\u521D\u59CB\u5316");
1146
- const { deltaY, deltaX } = event;
1147
- if (this.page.clientHeight < this.wrapperHeight && deltaY)
1148
- return;
1149
- if (this.page.clientWidth < this.wrapperWidth && deltaX)
1150
- return;
1151
- if (this.maxScrollTop > 0) {
1152
- this.scrollTop = this.scrollTop + deltaY;
1153
- }
1154
- if (this.maxScrollLeft > 0) {
1155
- this.scrollLeft = this.scrollLeft + deltaX;
1156
- }
1157
- this.scroll();
1158
- this.emit("scroll", event);
1159
- };
1160
- mouseLeaveHandler = () => {
1161
- setTimeout(() => this.emit("clearHighlight"), throttleTime);
1162
- };
1163
- }
1164
-
1165
- class StageMultiDragResize extends EventEmitter.EventEmitter {
1166
- core;
1167
- mask;
1168
- container;
1169
- targetList = [];
1170
- dragElList = [];
1171
- moveableForMulti;
1172
- dragStatus = StageDragStatus.END;
1173
- multiMoveableHelper;
1174
- constructor(config) {
1175
- super();
1176
- this.core = config.core;
1177
- this.container = config.container;
1178
- this.mask = config.mask;
1179
- }
1180
- multiSelect(els) {
1181
- this.targetList = els;
1182
- this.core.dr.destroyDragEl();
1183
- this.destroyDragElList();
1184
- this.dragElList = els.map((elItem) => {
1185
- const dragElDiv = globalThis.document.createElement("div");
1186
- this.container.append(dragElDiv);
1187
- dragElDiv.style.cssText = getTargetElStyle(elItem);
1188
- dragElDiv.id = `${DRAG_EL_ID_PREFIX}${elItem.id}`;
1189
- if (typeof this.core.config.updateDragEl === "function") {
1190
- this.core.config.updateDragEl(dragElDiv, elItem);
1191
- }
1192
- return dragElDiv;
1193
- });
1194
- this.moveableForMulti?.destroy();
1195
- this.multiMoveableHelper?.clear();
1196
- this.moveableForMulti = new Moveable__default.default(
1197
- this.container,
1198
- this.getOptions({
1199
- target: this.dragElList
1200
- })
1201
- );
1202
- this.multiMoveableHelper = MoveableHelper__default.default.create({
1203
- useBeforeRender: true,
1204
- useRender: false,
1205
- createAuto: true
1206
- });
1207
- const frames = [];
1208
- const setFrames = (events) => {
1209
- events.forEach((ev) => {
1210
- const matchEventTarget = this.targetList.find(
1211
- (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
1212
- );
1213
- if (!matchEventTarget)
1214
- return;
1215
- frames.push({
1216
- left: matchEventTarget.offsetLeft,
1217
- top: matchEventTarget.offsetTop,
1218
- id: matchEventTarget.id
1219
- });
1220
- });
1221
- };
1222
- this.moveableForMulti.on("resizeGroupStart", (params) => {
1223
- const { events } = params;
1224
- this.multiMoveableHelper?.onResizeGroupStart(params);
1225
- setFrames(events);
1226
- this.dragStatus = StageDragStatus.START;
1227
- }).on("resizeGroup", (params) => {
1228
- const { events } = params;
1229
- events.forEach((ev) => {
1230
- const { width, height, beforeTranslate } = ev.drag;
1231
- const frameSnapShot = frames.find(
1232
- (frameItem) => frameItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
1233
- );
1234
- if (!frameSnapShot)
1235
- return;
1236
- const targeEl = this.targetList.find(
1237
- (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
1238
- );
1239
- if (!targeEl)
1240
- return;
1241
- const isParentIncluded = this.targetList.find((targetItem) => targetItem.id === targeEl.parentElement?.id);
1242
- if (!isParentIncluded) {
1243
- targeEl.style.left = `${frameSnapShot.left + beforeTranslate[0]}px`;
1244
- targeEl.style.top = `${frameSnapShot.top + beforeTranslate[1]}px`;
1245
- }
1246
- targeEl.style.width = `${width}px`;
1247
- targeEl.style.height = `${height}px`;
1248
- });
1249
- this.multiMoveableHelper?.onResizeGroup(params);
1250
- this.dragStatus = StageDragStatus.ING;
1251
- }).on("resizeGroupEnd", () => {
1252
- this.update(true);
1253
- this.dragStatus = StageDragStatus.END;
1254
- }).on("dragGroupStart", (params) => {
1255
- const { events } = params;
1256
- this.multiMoveableHelper?.onDragGroupStart(params);
1257
- setFrames(events);
1258
- this.dragStatus = StageDragStatus.START;
1259
- }).on("dragGroup", (params) => {
1260
- const { events } = params;
1261
- events.forEach((ev) => {
1262
- const frameSnapShot = frames.find(
1263
- (frameItem) => frameItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
1264
- );
1265
- if (!frameSnapShot)
1266
- return;
1267
- const targeEl = this.targetList.find(
1268
- (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
1269
- );
1270
- if (!targeEl)
1271
- return;
1272
- const isParentIncluded = this.targetList.find((targetItem) => targetItem.id === targeEl.parentElement?.id);
1273
- if (!isParentIncluded) {
1274
- targeEl.style.left = `${frameSnapShot.left + ev.beforeTranslate[0]}px`;
1275
- targeEl.style.top = `${frameSnapShot.top + ev.beforeTranslate[1]}px`;
1276
- }
1765
+ left: scrollLeft
1277
1766
  });
1278
- this.multiMoveableHelper?.onDragGroup(params);
1279
- this.dragStatus = StageDragStatus.ING;
1280
- }).on("dragGroupEnd", () => {
1281
- this.update();
1282
- this.dragStatus = StageDragStatus.END;
1283
- }).on("clickGroup", (params) => {
1284
- const { inputTarget, targets } = params;
1285
- if (!this.mask.isMultiSelectStatus && targets.length > 1 && targets.includes(inputTarget)) {
1286
- this.emit("select", inputTarget.id.replace(DRAG_EL_ID_PREFIX, ""));
1767
+ }
1768
+ if (this.mode === Mode.FIXED) {
1769
+ scrollLeft = 0;
1770
+ scrollTop = 0;
1771
+ }
1772
+ this.scrollRule(scrollTop);
1773
+ this.scrollTo(scrollLeft, scrollTop);
1774
+ }
1775
+ scrollTo(scrollLeft, scrollTop) {
1776
+ this.content.style.transform = `translate3d(${-scrollLeft}px, ${-scrollTop}px, 0)`;
1777
+ const event = new CustomEvent("customScroll", {
1778
+ detail: {
1779
+ scrollLeft: this.scrollLeft,
1780
+ scrollTop: this.scrollTop
1287
1781
  }
1288
1782
  });
1783
+ this.content.dispatchEvent(event);
1289
1784
  }
1290
- canSelect(el, stop) {
1291
- if (el.className.includes(PAGE_CLASS)) {
1292
- this.core.highlightedDom = void 0;
1293
- this.core.highlightLayer.clearHighlight();
1294
- stop();
1295
- return false;
1296
- }
1297
- const currentTargetMode = getMode(el);
1298
- let selectedDomMode = "";
1299
- if (this.core.selectedDom?.className.includes(PAGE_CLASS)) {
1300
- return true;
1301
- }
1302
- if (this.targetList.length === 0 && this.core.selectedDom) {
1303
- selectedDomMode = getMode(this.core.selectedDom);
1304
- } else if (this.targetList.length > 0) {
1305
- selectedDomMode = getMode(this.targetList[0]);
1306
- }
1307
- if (currentTargetMode !== selectedDomMode) {
1308
- return false;
1309
- }
1310
- return true;
1785
+ setHeight(height) {
1786
+ this.height = height;
1787
+ this.setMaxScrollTop();
1788
+ this.content.style.height = `${height}px`;
1311
1789
  }
1312
- clearSelectStatus() {
1313
- if (!this.moveableForMulti)
1314
- return;
1315
- this.destroyDragElList();
1316
- this.moveableForMulti.target = null;
1317
- this.moveableForMulti.updateTarget();
1318
- this.targetList = [];
1790
+ setWidth(width) {
1791
+ this.width = width;
1792
+ this.setMaxScrollLeft();
1793
+ this.content.style.width = `${width}px`;
1319
1794
  }
1320
- destroy() {
1321
- this.moveableForMulti?.destroy();
1322
- this.destroyDragElList();
1795
+ setMaxScrollLeft() {
1796
+ this.maxScrollLeft = Math.max(this.width - this.wrapperWidth, 0);
1323
1797
  }
1324
- destroyDragElList() {
1325
- this.dragElList.forEach((dragElItem) => dragElItem?.remove());
1798
+ setMaxScrollTop() {
1799
+ this.maxScrollTop = Math.max(this.height - this.wrapperHeight, 0);
1326
1800
  }
1327
- update(isResize = false) {
1328
- if (this.targetList.length === 0)
1801
+ fixScrollValue() {
1802
+ if (this.scrollTop < 0)
1803
+ this.scrollTop = 0;
1804
+ if (this.scrollLeft < 0)
1805
+ this.scrollLeft = 0;
1806
+ if (this.maxScrollTop < this.scrollTop)
1807
+ this.scrollTop = this.maxScrollTop;
1808
+ if (this.maxScrollLeft < this.scrollLeft)
1809
+ this.scrollLeft = this.maxScrollLeft;
1810
+ }
1811
+ mouseWheelHandler = (event) => {
1812
+ if (!this.page)
1813
+ throw new Error("page \u672A\u521D\u59CB\u5316");
1814
+ const { deltaY, deltaX } = event;
1815
+ if (this.page.clientHeight < this.wrapperHeight && deltaY)
1329
1816
  return;
1330
- const { contentWindow } = this.core.renderer;
1331
- const doc = contentWindow?.document;
1332
- if (!doc)
1817
+ if (this.page.clientWidth < this.wrapperWidth && deltaX)
1333
1818
  return;
1334
- this.emit("update", {
1335
- data: this.targetList.map((targetItem) => {
1336
- const offset = { left: targetItem.offsetLeft, top: targetItem.offsetTop };
1337
- const left = calcValueByFontsize(doc, offset.left);
1338
- const top = calcValueByFontsize(doc, offset.top);
1339
- const width = calcValueByFontsize(doc, targetItem.clientWidth);
1340
- const height = calcValueByFontsize(doc, targetItem.clientHeight);
1341
- return {
1342
- el: targetItem,
1343
- style: isResize ? { left, top, width, height } : { left, top }
1344
- };
1345
- }),
1346
- parentEl: null
1347
- });
1348
- }
1349
- getOptions(options = {}) {
1350
- let { multiMoveableOptions = {} } = this.core.config;
1351
- if (typeof multiMoveableOptions === "function") {
1352
- multiMoveableOptions = multiMoveableOptions(this.core);
1819
+ if (this.maxScrollTop > 0) {
1820
+ this.scrollTop = this.scrollTop + deltaY;
1353
1821
  }
1354
- return {
1355
- defaultGroupRotate: 0,
1356
- defaultGroupOrigin: "50% 50%",
1357
- draggable: true,
1358
- resizable: true,
1359
- throttleDrag: 0,
1360
- startDragRotate: 0,
1361
- throttleDragRotate: 0,
1362
- zoom: 1,
1363
- origin: true,
1364
- padding: { left: 0, top: 0, right: 0, bottom: 0 },
1365
- snappable: true,
1366
- bounds: {
1367
- top: 0,
1368
- left: -1,
1369
- right: this.container.clientWidth - 1,
1370
- bottom: this.container.clientHeight,
1371
- ...multiMoveableOptions.bounds || {}
1372
- },
1373
- ...options,
1374
- ...multiMoveableOptions
1375
- };
1376
- }
1822
+ if (this.maxScrollLeft > 0) {
1823
+ this.scrollLeft = this.scrollLeft + deltaX;
1824
+ }
1825
+ this.scroll();
1826
+ this.emit("scroll", event);
1827
+ };
1377
1828
  }
1378
1829
 
1379
1830
  const style = ".tmagic-stage-container-highlight::after {\n content: '';\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n background-color: #000;\n opacity: .1;\n pointer-events: none;\n}\n\n.magic-ui-container.magic-layout-relative {\n min-height: 50px;\n}\n";
@@ -1383,13 +1834,13 @@
1383
1834
  runtime = null;
1384
1835
  iframe;
1385
1836
  runtimeUrl;
1386
- core;
1387
- render;
1388
- constructor({ core }) {
1837
+ zoom = DEFAULT_ZOOM;
1838
+ customizedRender;
1839
+ constructor({ runtimeUrl, zoom, customizedRender }) {
1389
1840
  super();
1390
- this.core = core;
1391
- this.runtimeUrl = core.config.runtimeUrl || "";
1392
- this.render = core.config.render;
1841
+ this.runtimeUrl = runtimeUrl || "";
1842
+ this.customizedRender = customizedRender;
1843
+ this.setZoom(zoom);
1393
1844
  this.iframe = globalThis.document.createElement("iframe");
1394
1845
  this.iframe.src = utils.isSameDomain(this.runtimeUrl) ? this.runtimeUrl : "";
1395
1846
  this.iframe.style.cssText = `
@@ -1407,6 +1858,31 @@
1407
1858
  this.emit("runtime-ready", runtime);
1408
1859
  }
1409
1860
  });
1861
+ async add(data) {
1862
+ const runtime = await this.getRuntime();
1863
+ return runtime?.add?.(data);
1864
+ }
1865
+ async remove(data) {
1866
+ const runtime = await this.getRuntime();
1867
+ return runtime?.remove?.(data);
1868
+ }
1869
+ async update(data) {
1870
+ const runtime = await this.getRuntime();
1871
+ runtime?.update?.(data);
1872
+ }
1873
+ async select(els) {
1874
+ const runtime = await this.getRuntime();
1875
+ for (const el of els) {
1876
+ await runtime?.select?.(el.id);
1877
+ if (runtime?.beforeSelect) {
1878
+ await runtime.beforeSelect(el);
1879
+ }
1880
+ this.flagSelectedEl(el);
1881
+ }
1882
+ }
1883
+ setZoom(zoom = DEFAULT_ZOOM) {
1884
+ this.zoom = zoom;
1885
+ }
1410
1886
  async mount(el) {
1411
1887
  if (!this.iframe) {
1412
1888
  throw Error("mount \u5931\u8D25");
@@ -1432,6 +1908,30 @@
1432
1908
  this.on("runtime-ready", listener);
1433
1909
  });
1434
1910
  };
1911
+ getDocument() {
1912
+ return this.contentWindow?.document;
1913
+ }
1914
+ getElementsFromPoint(point) {
1915
+ let x = point.clientX;
1916
+ let y = point.clientY;
1917
+ if (this.iframe) {
1918
+ const rect = this.iframe.getClientRects()[0];
1919
+ if (rect) {
1920
+ x = x - rect.left;
1921
+ y = y - rect.top;
1922
+ }
1923
+ }
1924
+ return this.getDocument()?.elementsFromPoint(x / this.zoom, y / this.zoom);
1925
+ }
1926
+ getTargetElement(idOrEl) {
1927
+ if (typeof idOrEl === "string" || typeof idOrEl === "number") {
1928
+ const el = this.getDocument()?.getElementById(`${idOrEl}`);
1929
+ if (!el)
1930
+ throw new Error(`\u4E0D\u5B58\u5728ID\u4E3A${idOrEl}\u7684\u5143\u7D20`);
1931
+ return el;
1932
+ }
1933
+ return idOrEl;
1934
+ }
1435
1935
  destroy() {
1436
1936
  this.iframe?.removeEventListener("load", this.loadHandler);
1437
1937
  this.contentWindow = null;
@@ -1439,14 +1939,21 @@
1439
1939
  this.iframe = void 0;
1440
1940
  this.removeAllListeners();
1441
1941
  }
1942
+ flagSelectedEl(el) {
1943
+ const doc = this.getDocument();
1944
+ if (doc) {
1945
+ removeSelectedClassName(doc);
1946
+ addSelectedClassName(el, doc);
1947
+ }
1948
+ }
1442
1949
  loadHandler = async () => {
1443
1950
  if (!this.contentWindow?.magic) {
1444
1951
  this.postTmagicRuntimeReady();
1445
1952
  }
1446
1953
  if (!this.contentWindow)
1447
1954
  return;
1448
- if (this.render) {
1449
- const el = await this.render(this.core);
1955
+ if (this.customizedRender) {
1956
+ const el = await this.customizedRender();
1450
1957
  if (el) {
1451
1958
  this.contentWindow.document?.body?.appendChild(el);
1452
1959
  }
@@ -1468,205 +1975,79 @@
1468
1975
 
1469
1976
  class StageCore extends EventEmitter.EventEmitter {
1470
1977
  container;
1471
- selectedDom;
1472
- selectedDomList = [];
1473
- highlightedDom;
1474
1978
  renderer;
1475
1979
  mask;
1476
- dr;
1477
- multiDr;
1478
- highlightLayer;
1479
- config;
1480
- zoom = DEFAULT_ZOOM;
1481
- containerHighlightClassName;
1482
- containerHighlightDuration;
1483
- containerHighlightType;
1484
- isContainer;
1485
- canSelect;
1980
+ actionManager;
1981
+ pageResizeObserver = null;
1982
+ autoScrollIntoView;
1983
+ customizedRender;
1486
1984
  constructor(config) {
1487
1985
  super();
1488
- this.config = config;
1489
- this.setZoom(config.zoom);
1490
- this.canSelect = config.canSelect || ((el) => !!el.id);
1491
- this.isContainer = config.isContainer;
1492
- this.containerHighlightClassName = config.containerHighlightClassName || CONTAINER_HIGHLIGHT_CLASS;
1493
- this.containerHighlightDuration = config.containerHighlightDuration || 800;
1494
- this.containerHighlightType = config.containerHighlightType;
1495
- this.renderer = new StageRender({ core: this });
1496
- this.mask = new StageMask({ core: this });
1497
- this.dr = new StageDragResize({ core: this, container: this.mask.content, mask: this.mask });
1498
- this.multiDr = new StageMultiDragResize({ core: this, container: this.mask.content, mask: this.mask });
1499
- this.highlightLayer = new StageHighlight({ core: this, container: this.mask.wrapper });
1500
- this.renderer.on("runtime-ready", (runtime) => {
1501
- this.emit("runtime-ready", runtime);
1502
- });
1503
- this.renderer.on("page-el-update", (el) => {
1504
- this.mask?.observe(el);
1505
- });
1506
- this.mask.on("beforeSelect", async (event) => {
1507
- this.clearSelectStatus("multiSelect");
1508
- const el = await this.getElementFromPoint(event);
1509
- if (!el)
1510
- return;
1511
- this.select(el, event);
1512
- }).on("select", () => {
1513
- this.emit("select", this.selectedDom);
1514
- }).on("changeGuides", (data) => {
1515
- this.dr.setGuidelines(data.type, data.guides);
1516
- this.emit("changeGuides", data);
1517
- }).on("highlight", async (event) => {
1518
- const el = await this.getElementFromPoint(event);
1519
- if (!el)
1520
- return;
1521
- if (this.multiDr.dragStatus === StageDragStatus.ING)
1522
- return;
1523
- await this.highlight(el);
1524
- if (this.highlightedDom === this.selectedDom) {
1525
- this.highlightLayer.clearHighlight();
1526
- return;
1527
- }
1528
- this.emit("highlight", this.highlightedDom);
1529
- }).on("clearHighlight", async () => {
1530
- this.highlightLayer.clearHighlight();
1531
- }).on("beforeMultiSelect", async (event) => {
1532
- const el = await this.getElementFromPoint(event);
1533
- if (!el)
1534
- return;
1535
- if (this.selectedDom && !this.selectedDom.className.includes(PAGE_CLASS)) {
1536
- this.selectedDomList.push(this.selectedDom);
1537
- this.selectedDom = void 0;
1538
- }
1539
- const existIndex = this.selectedDomList.findIndex((selectedDom) => selectedDom.id === el.id);
1540
- if (existIndex !== -1) {
1541
- this.selectedDomList.splice(existIndex, 1);
1542
- } else {
1543
- this.selectedDomList.push(el);
1986
+ this.autoScrollIntoView = config.autoScrollIntoView;
1987
+ this.customizedRender = config.render;
1988
+ this.renderer = new StageRender({
1989
+ runtimeUrl: config.runtimeUrl,
1990
+ zoom: config.zoom,
1991
+ customizedRender: async () => {
1992
+ if (this?.customizedRender) {
1993
+ return await this.customizedRender(this);
1994
+ }
1995
+ return null;
1544
1996
  }
1545
- this.multiSelect(this.selectedDomList);
1546
- });
1547
- this.dr.on("update", (data) => {
1548
- setTimeout(() => this.emit("update", data));
1549
- }).on("sort", (data) => {
1550
- setTimeout(() => this.emit("sort", data));
1551
- });
1552
- this.multiDr.on("update", (data) => {
1553
- setTimeout(() => this.emit("update", data));
1554
- }).on("select", async (id) => {
1555
- const el = await this.getTargetElement(id);
1556
- this.select(el);
1557
- setTimeout(() => this.emit("select", el));
1558
1997
  });
1559
- }
1560
- getElementsFromPoint(event) {
1561
- const { renderer, zoom } = this;
1562
- const doc = renderer.contentWindow?.document;
1563
- let x = event.clientX;
1564
- let y = event.clientY;
1565
- if (renderer.iframe) {
1566
- const rect = renderer.iframe.getClientRects()[0];
1567
- if (rect) {
1568
- x = x - rect.left;
1569
- y = y - rect.top;
1570
- }
1571
- }
1572
- return doc?.elementsFromPoint(x / zoom, y / zoom);
1573
- }
1574
- async getElementFromPoint(event) {
1575
- const els = this.getElementsFromPoint(event);
1576
- let stopped = false;
1577
- const stop = () => stopped = true;
1578
- for (const el of els) {
1579
- if (!el.id.startsWith(GHOST_EL_ID_PREFIX) && await this.isElCanSelect(el, event, stop)) {
1580
- if (stopped)
1581
- break;
1582
- return el;
1583
- }
1584
- }
1585
- }
1586
- async isElCanSelect(el, event, stop) {
1587
- const canSelectByProp = await this.canSelect(el, event, stop);
1588
- if (!canSelectByProp)
1589
- return false;
1590
- if (this.mask.isMultiSelectStatus) {
1591
- return this.multiDr.canSelect(el, stop);
1592
- }
1593
- return true;
1998
+ this.mask = new StageMask();
1999
+ this.actionManager = new ActionManager(this.getActionManagerConfig(config));
2000
+ this.initRenderEvent();
2001
+ this.initActionEvent();
2002
+ this.initMaskEvent();
1594
2003
  }
1595
2004
  async select(idOrEl, event) {
1596
- this.clearSelectStatus("multiSelect");
1597
- const el = await this.getTargetElement(idOrEl);
1598
- if (el === this.selectedDom)
2005
+ const el = this.renderer.getTargetElement(idOrEl);
2006
+ if (el === this.actionManager.getSelectedEl())
1599
2007
  return;
1600
- const runtime = await this.renderer.getRuntime();
1601
- await runtime?.select?.(el.id);
1602
- if (runtime?.beforeSelect) {
1603
- await runtime.beforeSelect(el);
1604
- }
2008
+ await this.renderer.select([el]);
1605
2009
  this.mask.setLayout(el);
1606
- this.dr.select(el, event);
1607
- if (this.config.autoScrollIntoView || el.dataset.autoScrollIntoView) {
1608
- this.mask.intersectionObserver?.observe(el);
1609
- }
1610
- this.selectedDom = el;
1611
- if (this.renderer.contentWindow) {
1612
- removeSelectedClassName(this.renderer.contentWindow.document);
1613
- if (this.selectedDom) {
1614
- addSelectedClassName(this.selectedDom, this.renderer.contentWindow.document);
1615
- }
2010
+ this.actionManager.select(el, event);
2011
+ if (this.autoScrollIntoView || el.dataset.autoScrollIntoView) {
2012
+ this.mask.observerIntersection(el);
1616
2013
  }
1617
2014
  }
1618
2015
  async multiSelect(idOrElList) {
1619
- this.clearSelectStatus("select");
1620
- const elList = await Promise.all(idOrElList.map(async (idOrEl) => await this.getTargetElement(idOrEl)));
1621
- this.multiDr.multiSelect(elList);
1622
- this.emit("multiSelect", elList);
1623
- }
1624
- update(data) {
1625
- const { config } = data;
1626
- return this.renderer?.getRuntime().then((runtime) => {
1627
- runtime?.update?.(data);
1628
- setTimeout(() => {
1629
- const el = this.renderer.contentWindow?.document.getElementById(`${config.id}`);
1630
- if (el && el.id === this.selectedDom?.id) {
1631
- this.selectedDom = el;
1632
- this.mask.setLayout(el);
1633
- this.dr.updateMoveable(el);
1634
- }
1635
- }, 0);
1636
- });
1637
- }
1638
- async highlight(idOrEl) {
1639
- let el;
1640
- try {
1641
- el = await this.getTargetElement(idOrEl);
1642
- } catch (error) {
1643
- this.highlightLayer.clearHighlight();
2016
+ const els = idOrElList.map((idOrEl) => this.renderer.getTargetElement(idOrEl));
2017
+ if (els.length === 0)
1644
2018
  return;
2019
+ const lastEl = els[els.length - 1];
2020
+ const isReduceSelect = els.length < this.actionManager.getSelectedElList().length;
2021
+ await this.renderer.select(els);
2022
+ this.mask.setLayout(lastEl);
2023
+ this.actionManager.multiSelect(idOrElList);
2024
+ if ((this.autoScrollIntoView || lastEl.dataset.autoScrollIntoView) && !isReduceSelect) {
2025
+ this.mask.observerIntersection(lastEl);
1645
2026
  }
1646
- if (el === this.highlightedDom || !el)
1647
- return;
1648
- this.highlightLayer.highlight(el);
1649
- this.highlightedDom = el;
1650
2027
  }
1651
- sortNode(data) {
1652
- return this.renderer?.getRuntime().then((runtime) => runtime?.sortNode?.(data));
2028
+ highlight(idOrEl) {
2029
+ this.actionManager.highlight(idOrEl);
1653
2030
  }
1654
- add(data) {
1655
- return this.renderer?.getRuntime().then((runtime) => runtime?.add?.(data));
2031
+ async update(data) {
2032
+ const { config } = data;
2033
+ await this.renderer.update(data);
2034
+ setTimeout(() => {
2035
+ const el = this.renderer.getTargetElement(`${config.id}`);
2036
+ if (el && this.actionManager.isSelectedEl(el)) {
2037
+ this.mask.setLayout(el);
2038
+ this.actionManager.setSelectedEl(el);
2039
+ this.actionManager.updateMoveable(el);
2040
+ }
2041
+ });
1656
2042
  }
1657
- remove(data) {
1658
- return this.renderer?.getRuntime().then((runtime) => runtime?.remove?.(data));
2043
+ async add(data) {
2044
+ return await this.renderer.add(data);
1659
2045
  }
1660
- setZoom(zoom = DEFAULT_ZOOM) {
1661
- this.zoom = zoom;
2046
+ async remove(data) {
2047
+ return await this.renderer.remove(data);
1662
2048
  }
1663
- clearSelectStatus(selectType) {
1664
- if (selectType === "multiSelect") {
1665
- this.multiDr.clearSelectStatus();
1666
- this.selectedDomList = [];
1667
- } else {
1668
- this.dr.clearSelectStatus();
1669
- }
2049
+ setZoom(zoom = DEFAULT_ZOOM) {
2050
+ this.renderer.setZoom(zoom);
1670
2051
  }
1671
2052
  async mount(el) {
1672
2053
  this.container = el;
@@ -1677,47 +2058,107 @@
1677
2058
  }
1678
2059
  clearGuides() {
1679
2060
  this.mask.clearGuides();
1680
- this.dr.clearGuides();
2061
+ this.actionManager.clearGuides();
1681
2062
  }
1682
- async addContainerHighlightClassName(event, exclude) {
1683
- const els = this.getElementsFromPoint(event);
1684
- const { renderer } = this;
1685
- const doc = renderer.contentWindow?.document;
1686
- if (!doc)
1687
- return;
1688
- for (const el of els) {
1689
- if (!el.id.startsWith(GHOST_EL_ID_PREFIX) && await this.isContainer(el) && !exclude.includes(el)) {
1690
- utils.addClassName(el, doc, this.containerHighlightClassName);
1691
- break;
1692
- }
1693
- }
2063
+ getAddContainerHighlightClassNameTimeout(event, excludeElList = []) {
2064
+ return this.delayedMarkContainer(event, excludeElList);
1694
2065
  }
1695
- getAddContainerHighlightClassNameTimeout(event, exclude = []) {
1696
- return globalThis.setTimeout(() => {
1697
- this.addContainerHighlightClassName(event, exclude);
1698
- }, this.containerHighlightDuration);
2066
+ delayedMarkContainer(event, excludeElList = []) {
2067
+ return this.actionManager.delayedMarkContainer(event, excludeElList);
1699
2068
  }
1700
2069
  destroy() {
1701
- const { mask, renderer, dr, highlightLayer } = this;
2070
+ const { mask, renderer, actionManager, pageResizeObserver } = this;
1702
2071
  renderer.destroy();
1703
2072
  mask.destroy();
1704
- dr.destroy();
1705
- highlightLayer.destroy();
2073
+ actionManager.destroy();
2074
+ pageResizeObserver?.disconnect();
1706
2075
  this.removeAllListeners();
1707
2076
  this.container = void 0;
1708
2077
  }
1709
- async getTargetElement(idOrEl) {
1710
- if (typeof idOrEl === "string" || typeof idOrEl === "number") {
1711
- const el = this.renderer.contentWindow?.document.getElementById(`${idOrEl}`);
1712
- if (!el)
1713
- throw new Error(`\u4E0D\u5B58\u5728ID\u4E3A${idOrEl}\u7684\u5143\u7D20`);
1714
- return el;
2078
+ observePageResize(page) {
2079
+ if (typeof ResizeObserver !== "undefined") {
2080
+ this.pageResizeObserver = new ResizeObserver((entries) => {
2081
+ this.mask.pageResize(entries);
2082
+ this.actionManager.updateMoveable();
2083
+ });
2084
+ this.pageResizeObserver.observe(page);
1715
2085
  }
1716
- return idOrEl;
2086
+ }
2087
+ getActionManagerConfig(config) {
2088
+ const actionManagerConfig = {
2089
+ containerHighlightClassName: config.containerHighlightClassName,
2090
+ containerHighlightDuration: config.containerHighlightDuration,
2091
+ containerHighlightType: config.containerHighlightType,
2092
+ moveableOptions: config.moveableOptions,
2093
+ multiMoveableOptions: config.multiMoveableOptions,
2094
+ container: this.mask.content,
2095
+ canSelect: config.canSelect,
2096
+ isContainer: config.isContainer,
2097
+ updateDragEl: config.updateDragEl,
2098
+ getRootContainer: () => this.container,
2099
+ getRenderDocument: () => this.renderer.getDocument(),
2100
+ getTargetElement: (idOrEl) => this.renderer.getTargetElement(idOrEl),
2101
+ getElementsFromPoint: (point) => this.renderer.getElementsFromPoint(point)
2102
+ };
2103
+ return actionManagerConfig;
2104
+ }
2105
+ initRenderEvent() {
2106
+ this.renderer.on("runtime-ready", (runtime) => {
2107
+ this.emit("runtime-ready", runtime);
2108
+ });
2109
+ this.renderer.on("page-el-update", (el) => {
2110
+ this.mask?.observe(el);
2111
+ this.observePageResize(el);
2112
+ });
2113
+ }
2114
+ initMaskEvent() {
2115
+ this.mask.on("change-guides", (data) => {
2116
+ this.actionManager.setGuidelines(data.type, data.guides);
2117
+ this.emit("change-guides", data);
2118
+ });
2119
+ }
2120
+ initActionEvent() {
2121
+ this.initActionManagerEvent();
2122
+ this.initDrEvent();
2123
+ this.initMulDrEvent();
2124
+ this.initHighlightEvent();
2125
+ }
2126
+ initActionManagerEvent() {
2127
+ this.actionManager.on("before-select", (idOrEl, event) => {
2128
+ this.select(idOrEl, event);
2129
+ }).on("select", (selectedEl) => {
2130
+ this.emit("select", selectedEl);
2131
+ }).on("before-multi-select", (idOrElList) => {
2132
+ this.multiSelect(idOrElList);
2133
+ }).on("multi-select", (selectedElList) => {
2134
+ this.emit("multi-select", selectedElList);
2135
+ });
2136
+ }
2137
+ initDrEvent() {
2138
+ this.actionManager.on("update", (data) => {
2139
+ this.emit("update", data);
2140
+ }).on("sort", (data) => {
2141
+ this.emit("sort", data);
2142
+ }).on("select-parent", () => {
2143
+ this.emit("select-parent");
2144
+ });
2145
+ }
2146
+ initMulDrEvent() {
2147
+ this.actionManager.on("change-to-select", (el) => {
2148
+ this.select(el);
2149
+ setTimeout(() => this.emit("select", el));
2150
+ }).on("multi-update", (data, parentEl) => {
2151
+ this.emit("update", { data, parentEl });
2152
+ });
2153
+ }
2154
+ initHighlightEvent() {
2155
+ this.actionManager.on("highlight", async (highlightEl) => {
2156
+ this.emit("highlight", highlightEl);
2157
+ });
1717
2158
  }
1718
2159
  }
1719
2160
 
1720
- exports.CONTAINER_HIGHLIGHT_CLASS = CONTAINER_HIGHLIGHT_CLASS;
2161
+ exports.CONTAINER_HIGHLIGHT_CLASS_NAME = CONTAINER_HIGHLIGHT_CLASS_NAME;
1721
2162
  exports.ContainerHighlightType = ContainerHighlightType;
1722
2163
  exports.DEFAULT_ZOOM = DEFAULT_ZOOM;
1723
2164
  exports.DRAG_EL_ID_PREFIX = DRAG_EL_ID_PREFIX;
@@ -1728,6 +2169,7 @@
1728
2169
  exports.MouseButton = MouseButton;
1729
2170
  exports.PAGE_CLASS = PAGE_CLASS;
1730
2171
  exports.SELECTED_CLASS = SELECTED_CLASS;
2172
+ exports.SelectStatus = SelectStatus;
1731
2173
  exports.StageDragResize = StageDragResize;
1732
2174
  exports.StageDragStatus = StageDragStatus;
1733
2175
  exports.StageMask = StageMask;
@@ -1745,6 +2187,7 @@
1745
2187
  exports.isAbsolute = isAbsolute;
1746
2188
  exports.isFixed = isFixed;
1747
2189
  exports.isFixedParent = isFixedParent;
2190
+ exports.isMoveableButton = isMoveableButton;
1748
2191
  exports.isRelative = isRelative;
1749
2192
  exports.isStatic = isStatic;
1750
2193
  exports.removeSelectedClassName = removeSelectedClassName;
@@ -1753,4 +2196,4 @@
1753
2196
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
1754
2197
 
1755
2198
  }));
1756
- //# sourceMappingURL=tmagic-stage.umd.js.map
2199
+ //# sourceMappingURL=tmagic-stage.umd.cjs.map