@tmagic/stage 1.2.6 → 1.2.7

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.
@@ -514,9 +514,33 @@ class DragResizeHelper {
514
514
  }
515
515
  }
516
516
 
517
- const selectParentAbles = (selectParentHandler) => ({
518
- name: "select-parent",
519
- props: {},
517
+ var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
518
+ ContainerHighlightType2["DEFAULT"] = "default";
519
+ ContainerHighlightType2["ALT"] = "alt";
520
+ return ContainerHighlightType2;
521
+ })(ContainerHighlightType || {});
522
+ var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
523
+ SelectStatus2["SELECT"] = "select";
524
+ SelectStatus2["MULTI_SELECT"] = "multiSelect";
525
+ return SelectStatus2;
526
+ })(SelectStatus || {});
527
+ var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
528
+ StageDragStatus2["START"] = "start";
529
+ StageDragStatus2["ING"] = "ing";
530
+ StageDragStatus2["END"] = "end";
531
+ return StageDragStatus2;
532
+ })(StageDragStatus || {});
533
+ var AbleActionEventType = /* @__PURE__ */ ((AbleActionEventType2) => {
534
+ AbleActionEventType2["SELECT_PARENT"] = "select-parent";
535
+ AbleActionEventType2["REMOVE"] = "remove";
536
+ return AbleActionEventType2;
537
+ })(AbleActionEventType || {});
538
+
539
+ const MoveableActionsAble = (handler) => ({
540
+ name: "actions",
541
+ props: {
542
+ selectParent: Boolean
543
+ },
520
544
  events: {},
521
545
  render(moveable, React) {
522
546
  const rect = moveable.getRect();
@@ -542,6 +566,23 @@ const selectParentAbles = (selectParentHandler) => ({
542
566
  color: white;
543
567
  font-size: 12px;
544
568
  font-weight: bold;
569
+ margin-left: 2px;
570
+ position: relative;
571
+ }
572
+ .moveable-remove-button:before, .moveable-remove-button:after {
573
+ content: "";
574
+ position: absolute;
575
+ left: 50%;
576
+ top: 50%;
577
+ transform: translate(-50%, -50%) rotate(45deg);
578
+ width: 14px;
579
+ height: 2px;
580
+ background: #fff;
581
+ border-radius: 1px;
582
+ cursor: pointer;
583
+ }
584
+ .moveable-remove-button:after {
585
+ transform: translate(-50%, -50%) rotate(-45deg);
545
586
  }
546
587
  `
547
588
  );
@@ -550,37 +591,49 @@ const selectParentAbles = (selectParentHandler) => ({
550
591
  {
551
592
  className: "moveable-editable",
552
593
  style: {
553
- transform: `translate(${pos2[0] - 25}px, ${pos2[1] - 30}px) rotate(${rect.rotation}deg) translate(10px)`
594
+ transform: `translate(${pos2[0] - 48}px, ${pos2[1] - 28}px) rotate(${rect.rotation}deg) translate(10px)`
554
595
  }
555
596
  },
556
- React.createElement(
557
- "button",
558
- {
559
- className: "moveable-button",
560
- title: "\u9009\u4E2D\u7236\u7EC4\u4EF6",
561
- onClick: () => {
562
- selectParentHandler();
563
- }
564
- },
597
+ [
565
598
  React.createElement(
566
- "svg",
599
+ "button",
567
600
  {
568
- width: "1em",
569
- height: "1em",
570
- viewBox: "0 0 16 16",
571
- fill: "none",
572
- xmlns: "http://www.w3.org/2000/svg",
573
- style: {
574
- transform: "rotate(90deg)"
601
+ className: "moveable-button",
602
+ title: "\u9009\u4E2D\u7236\u7EC4\u4EF6",
603
+ onClick: () => {
604
+ handler(AbleActionEventType.SELECT_PARENT);
575
605
  }
576
606
  },
577
- React.createElement("path", {
578
- 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",
579
- fill: "currentColor",
580
- fillOpacity: "0.9"
581
- })
582
- )
583
- )
607
+ React.createElement(
608
+ "svg",
609
+ {
610
+ width: "20px",
611
+ height: "20px",
612
+ viewBox: "0 0 16 16",
613
+ fill: "none",
614
+ xmlns: "http://www.w3.org/2000/svg",
615
+ style: {
616
+ transform: "rotate(90deg)",
617
+ position: "absolute",
618
+ left: 0,
619
+ top: 0
620
+ }
621
+ },
622
+ React.createElement("path", {
623
+ 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",
624
+ fill: "currentColor",
625
+ fillOpacity: "0.9"
626
+ })
627
+ )
628
+ ),
629
+ React.createElement("button", {
630
+ className: "moveable-button moveable-remove-button",
631
+ title: "\u5220\u9664",
632
+ onClick: () => {
633
+ handler(AbleActionEventType.REMOVE);
634
+ }
635
+ })
636
+ ]
584
637
  );
585
638
  }
586
639
  });
@@ -676,9 +729,9 @@ class MoveableOptionsManager extends EventEmitter {
676
729
  },
677
730
  isDisplayInnerSnapDigit: true,
678
731
  props: {
679
- selectParent: true
732
+ actions: true
680
733
  },
681
- ables: [selectParentAbles(this.selectParentHandler.bind(this))]
734
+ ables: [MoveableActionsAble(this.actionHandler.bind(this))]
682
735
  };
683
736
  }
684
737
  getMultiOptions() {
@@ -697,8 +750,8 @@ class MoveableOptionsManager extends EventEmitter {
697
750
  }
698
751
  return this.customizedOptions;
699
752
  }
700
- selectParentHandler() {
701
- this.emit("select-parent");
753
+ actionHandler(type) {
754
+ this.emit(type);
702
755
  }
703
756
  createGuidelineElements(selectedElList, allElList) {
704
757
  const frame = globalThis.document.createDocumentFragment();
@@ -723,23 +776,6 @@ class MoveableOptionsManager extends EventEmitter {
723
776
  }
724
777
  }
725
778
 
726
- var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
727
- ContainerHighlightType2["DEFAULT"] = "default";
728
- ContainerHighlightType2["ALT"] = "alt";
729
- return ContainerHighlightType2;
730
- })(ContainerHighlightType || {});
731
- var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
732
- SelectStatus2["SELECT"] = "select";
733
- SelectStatus2["MULTI_SELECT"] = "multiSelect";
734
- return SelectStatus2;
735
- })(SelectStatus || {});
736
- var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
737
- StageDragStatus2["START"] = "start";
738
- StageDragStatus2["ING"] = "ing";
739
- StageDragStatus2["END"] = "end";
740
- return StageDragStatus2;
741
- })(StageDragStatus || {});
742
-
743
779
  class StageDragResize extends MoveableOptionsManager {
744
780
  target;
745
781
  moveable;
@@ -765,6 +801,9 @@ class StageDragResize extends MoveableOptionsManager {
765
801
  }
766
802
  });
767
803
  }
804
+ getTarget() {
805
+ return this.target;
806
+ }
768
807
  select(el, event) {
769
808
  if (!this.moveable || el !== this.target) {
770
809
  this.initMoveable(el);
@@ -1437,6 +1476,14 @@ class ActionManager extends EventEmitter {
1437
1476
  setTimeout(() => this.emit("sort", data));
1438
1477
  }).on("select-parent", () => {
1439
1478
  this.emit("select-parent");
1479
+ }).on("remove", () => {
1480
+ const drTarget = this.dr.getTarget();
1481
+ if (!drTarget)
1482
+ return;
1483
+ const data = {
1484
+ data: [{ el: drTarget }]
1485
+ };
1486
+ this.emit("remove", data);
1440
1487
  });
1441
1488
  this.multiDr.on("update", (data, parentEl) => {
1442
1489
  this.emit("multi-update", data, parentEl);
@@ -2140,6 +2187,8 @@ class StageCore extends EventEmitter$1 {
2140
2187
  this.emit("sort", data);
2141
2188
  }).on("select-parent", () => {
2142
2189
  this.emit("select-parent");
2190
+ }).on("remove", (data) => {
2191
+ this.emit("remove", data);
2143
2192
  });
2144
2193
  }
2145
2194
  initMulDrEvent() {
@@ -2157,5 +2206,5 @@ class StageCore extends EventEmitter$1 {
2157
2206
  }
2158
2207
  }
2159
2208
 
2160
- export { CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, PAGE_CLASS, SELECTED_CLASS, SelectStatus, StageDragResize, StageDragStatus, StageMask, StageRender, ZIndex, addSelectedClassName, calcValueByFontsize, StageCore as default, down, getAbsolutePosition, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
2209
+ export { AbleActionEventType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, PAGE_CLASS, SELECTED_CLASS, SelectStatus, StageDragResize, StageDragStatus, StageMask, StageRender, ZIndex, addSelectedClassName, calcValueByFontsize, StageCore as default, down, getAbsolutePosition, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
2161
2210
  //# sourceMappingURL=tmagic-stage.js.map