@vvfx/sdk 0.2.2-beta.5 → 0.2.2-beta.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.
@@ -62,6 +62,7 @@ export declare class HTMLOverlayManager {
62
62
  private handleContainerMouseDown;
63
63
  private handleContainerMouseMove;
64
64
  private handleContainerMouseLeave;
65
+ private isMouseLeaveWithinContainer;
65
66
  private handleContainerContextMenu;
66
67
  private isHTMLContextMenuEvent;
67
68
  private handleViewportTransform;
@@ -80,10 +81,13 @@ export declare class HTMLOverlayManager {
80
81
  private syncActiveContentInteraction;
81
82
  private scheduleActiveContentInteractionSync;
82
83
  private setActiveContentInteraction;
83
- private getContentInteractiveZoneByEvent;
84
+ private resolveHTMLInteractionTarget;
85
+ private getActiveSubtreeInteractionAtEvent;
86
+ private resolveContentInteractionZone;
84
87
  private getContentInteractionZones;
85
88
  private getContentInteractiveSelector;
86
89
  private isContentInteractionDisabled;
90
+ private getContentInteractionZoneMode;
87
91
  private invalidateContentInteractionZones;
88
92
  private observeContentInteractionZoneResizes;
89
93
  private getLayerPoint;
@@ -93,6 +97,7 @@ export declare class HTMLOverlayManager {
93
97
  private requestAutoHeightFromIframes;
94
98
  private syncContentInteraction;
95
99
  private syncContentInteractionZones;
100
+ private clearContentInteractionState;
96
101
  private syncShellInteraction;
97
102
  private enterEditing;
98
103
  private exitEditing;
@@ -8,7 +8,7 @@ export type CardOverlayBoxStyle = {
8
8
  contentHeight: number;
9
9
  transform: string;
10
10
  };
11
- export declare function getCardOverlayBoxStyle(box: Box2, width: number, height: number, offsetX?: number, offsetY?: number, autoScale?: boolean): CardOverlayBoxStyle;
11
+ export declare function getCardOverlayBoxStyle(box: Box2, width: number, height: number, offsetX?: number, offsetY?: number, _autoScale?: boolean): CardOverlayBoxStyle;
12
12
  export declare function isPointInCardOverlayBox(box: Box2, point: {
13
13
  x: number;
14
14
  y: number;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: TODO
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 赤芍,何即,不择,意绮
6
- * Version: v0.2.2-beta.5
6
+ * Version: v0.2.2-beta.7
7
7
  */
8
8
 
9
9
  import * as EFFECTS from '@galacean/effects';
@@ -55558,6 +55558,16 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55558
55558
  newWidth,
55559
55559
  newHeight
55560
55560
  ], translation1);
55561
+ } else if (selectedItem && selectedItems.length === 1 && isCardItem(selectedItem)) {
55562
+ void this._pageDataUtils.setItemProperty({
55563
+ itemId: selectedItem.id,
55564
+ type: SDKItemType.CARD,
55565
+ property: {
55566
+ width: selectedItem.width * resultScalar1.x,
55567
+ height: selectedItem.height * resultScalar1.y
55568
+ }
55569
+ });
55570
+ this._pageDataUtils.moveItem(selectedItem.id, translation1);
55561
55571
  } else {
55562
55572
  // 普通元素的缩放逻辑
55563
55573
  selectedItems.forEach(function(item) {
@@ -91824,14 +91834,13 @@ function syncElementStackOrder(_container, elements) {
91824
91834
  });
91825
91835
  }
91826
91836
 
91827
- function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, autoScale) {
91837
+ function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, _autoScale) {
91828
91838
  if (offsetX === void 0) offsetX = 0;
91829
91839
  if (offsetY === void 0) offsetY = 0;
91830
- if (autoScale === void 0) autoScale = true;
91831
91840
  if (box.corners.length === 4 && width > 0 && height > 0) {
91832
91841
  var _box_corners = box.corners, rightTop = _box_corners[0], leftBottom = _box_corners[2], leftTop = _box_corners[3];
91833
- var contentWidth = autoScale ? width : rightTop.distanceTo(leftTop);
91834
- var contentHeight = autoScale ? height : leftBottom.distanceTo(leftTop);
91842
+ var contentWidth = width;
91843
+ var contentHeight = height;
91835
91844
  var a = (rightTop.x - leftTop.x) / contentWidth;
91836
91845
  var b = (rightTop.y - leftTop.y) / contentWidth;
91837
91846
  var c = (leftBottom.x - leftTop.x) / contentHeight;
@@ -91904,8 +91913,8 @@ function mountHTMLShell(container, content, shell) {
91904
91913
  var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
91905
91914
  var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
91906
91915
  var CONTENT_INTERACTIVE_SELECTOR = [
91907
- '[data-interaction-zone="self"]',
91908
91916
  '[data-vvfx-html-interaction-zone="self"]',
91917
+ '[data-vvfx-html-interaction-zone="subtree"]',
91909
91918
  'a[href]',
91910
91919
  'button:not([disabled])',
91911
91920
  'input:not([disabled])',
@@ -91921,7 +91930,6 @@ var CONTENT_INTERACTIVE_SELECTOR = [
91921
91930
  '[tabindex]:not([tabindex="-1"])'
91922
91931
  ].join(', ');
91923
91932
  var CONTENT_INTERACTION_NONE_SELECTOR = [
91924
- '[data-interaction-zone="none"]',
91925
91933
  '[data-vvfx-html-interaction-zone="none"]'
91926
91934
  ].join(', ');
91927
91935
  var EDITING_VIEWPORT_PADDING = 48;
@@ -91995,7 +92003,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91995
92003
  _this.syncContentInteraction(hoverShellInteractiveId);
91996
92004
  }
91997
92005
  };
91998
- this.handleContainerMouseLeave = function() {
92006
+ this.handleContainerMouseLeave = function(event) {
92007
+ if (_this.isMouseLeaveWithinContainer(event)) {
92008
+ return;
92009
+ }
91999
92010
  if (_this.contentInteractionFrame !== undefined) {
92000
92011
  cancelAnimationFrame(_this.contentInteractionFrame);
92001
92012
  _this.contentInteractionFrame = undefined;
@@ -92236,6 +92247,17 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92236
92247
  this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
92237
92248
  this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
92238
92249
  };
92250
+ _proto.isMouseLeaveWithinContainer = function isMouseLeaveWithinContainer(event) {
92251
+ var relatedTarget = event.relatedTarget;
92252
+ if (!relatedTarget) {
92253
+ return false;
92254
+ }
92255
+ try {
92256
+ return this.options.container.contains(relatedTarget);
92257
+ } catch (unused) {
92258
+ return false;
92259
+ }
92260
+ };
92239
92261
  _proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
92240
92262
  if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
92241
92263
  return false;
@@ -92531,8 +92553,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92531
92553
  return undefined;
92532
92554
  };
92533
92555
  _proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
92534
- var zone = this.getContentInteractiveZoneByEvent(event);
92535
- this.setActiveContentInteraction(zone);
92556
+ var decision = this.resolveHTMLInteractionTarget(event);
92557
+ this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
92536
92558
  };
92537
92559
  _proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
92538
92560
  var _this = this;
@@ -92556,7 +92578,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92556
92578
  _proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
92557
92579
  var _this = this;
92558
92580
  var previous = this.state.activeContentInteraction;
92559
- if ((previous == null ? void 0 : previous.id) === (zone == null ? void 0 : zone.id) && (previous == null ? void 0 : previous.element) === (zone == null ? void 0 : zone.element)) {
92581
+ if ((previous == null ? void 0 : previous.id) === (zone == null ? void 0 : zone.id) && (previous == null ? void 0 : previous.element) === (zone == null ? void 0 : zone.element) && (previous == null ? void 0 : previous.zone) === (zone == null ? void 0 : zone.zone)) {
92560
92582
  return;
92561
92583
  }
92562
92584
  this.state.activeContentInteraction = zone;
@@ -92571,22 +92593,65 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92571
92593
  _this.syncContentInteraction(id);
92572
92594
  });
92573
92595
  };
92574
- _proto.getContentInteractiveZoneByEvent = function getContentInteractiveZoneByEvent(event) {
92596
+ _proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
92575
92597
  var id = this.getHTMLCardIdByEvent(event);
92576
92598
  if (!id || this.isEditableCard(id)) {
92577
- return undefined;
92599
+ return {
92600
+ kind: 'canvas',
92601
+ id: id
92602
+ };
92578
92603
  }
92579
92604
  var contentOverlay = this.state.contentElements.get(id);
92580
92605
  if (!contentOverlay) {
92581
- return undefined;
92606
+ return {
92607
+ kind: 'canvas',
92608
+ id: id
92609
+ };
92582
92610
  }
92583
- var zone = this.getContentInteractionZones(id, contentOverlay).find(function(zone) {
92611
+ var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
92612
+ if (activeSubtree) {
92613
+ return {
92614
+ kind: 'html',
92615
+ interaction: activeSubtree
92616
+ };
92617
+ }
92618
+ var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
92584
92619
  return isMouseEventInsideRect(event, zone.rect);
92585
92620
  });
92586
- return zone ? {
92587
- id: id,
92588
- element: zone.element
92589
- } : undefined;
92621
+ var zone = this.resolveContentInteractionZone(matchedZones);
92622
+ if (zone) {
92623
+ return {
92624
+ kind: 'html',
92625
+ interaction: {
92626
+ id: id,
92627
+ element: zone.element,
92628
+ zone: zone.zone
92629
+ }
92630
+ };
92631
+ }
92632
+ return {
92633
+ kind: 'canvas',
92634
+ id: id
92635
+ };
92636
+ };
92637
+ _proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
92638
+ var activeInteraction = this.state.activeContentInteraction;
92639
+ if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
92640
+ return undefined;
92641
+ }
92642
+ var rect = activeInteraction.element.getBoundingClientRect();
92643
+ return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
92644
+ };
92645
+ _proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
92646
+ if (zones.length <= 1) {
92647
+ return zones[0];
92648
+ }
92649
+ var subtreeRoot = zones.find(function(candidate) {
92650
+ return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
92651
+ return zone.element !== candidate.element && candidate.element.contains(zone.element);
92652
+ });
92653
+ });
92654
+ return subtreeRoot != null ? subtreeRoot : zones[0];
92590
92655
  };
92591
92656
  _proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
92592
92657
  var _this = this;
@@ -92599,7 +92664,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92599
92664
  }).map(function(element) {
92600
92665
  return {
92601
92666
  element: element,
92602
- rect: element.getBoundingClientRect()
92667
+ rect: element.getBoundingClientRect(),
92668
+ zone: _this.getContentInteractionZoneMode(element)
92603
92669
  };
92604
92670
  });
92605
92671
  this.state.contentInteractionZones.set(id, zones);
@@ -92629,6 +92695,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92629
92695
  }
92630
92696
  return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
92631
92697
  };
92698
+ _proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
92699
+ var zone = element.dataset.vvfxHtmlInteractionZone;
92700
+ return zone === 'subtree' ? 'subtree' : 'self';
92701
+ };
92632
92702
  _proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
92633
92703
  if (id) {
92634
92704
  var _this_state_contentInteractionResizeCleanups_get;
@@ -92741,11 +92811,11 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92741
92811
  var _this_state_editing, _this_state_activeContentInteraction;
92742
92812
  var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
92743
92813
  var activeInteraction = ((_this_state_activeContentInteraction = this.state.activeContentInteraction) == null ? void 0 : _this_state_activeContentInteraction.id) === id ? this.state.activeContentInteraction : undefined;
92744
- var isInteractive = isEditing || !!activeInteraction;
92745
92814
  var overlay = this.state.elements.get(id);
92746
92815
  var scaleOverlay = this.state.contentScaleElements.get(id);
92747
92816
  var contentOverlay = this.state.contentElements.get(id);
92748
92817
  var contentMount = this.state.contentMountElements.get(id);
92818
+ var isInteractive = isEditing || !!activeInteraction;
92749
92819
  if (overlay) {
92750
92820
  overlay.dataset.editing = isEditing ? 'true' : 'false';
92751
92821
  overlay.style.pointerEvents = 'none';
@@ -92763,7 +92833,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92763
92833
  iframe.tabIndex = isActiveIframe ? 0 : -1;
92764
92834
  });
92765
92835
  this.syncShellInteraction(id, contentOverlay, isInteractive);
92766
- this.syncContentInteractionZones(id, contentOverlay, activeInteraction == null ? void 0 : activeInteraction.element, isEditing, isInteractive);
92836
+ this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
92767
92837
  }
92768
92838
  if (contentMount) {
92769
92839
  contentMount.dataset.editing = isEditing ? 'true' : 'false';
@@ -92776,19 +92846,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92776
92846
  }
92777
92847
  }
92778
92848
  };
92779
- _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeElement, isEditing, isInteractive) {
92849
+ _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
92780
92850
  var _this = this;
92851
+ var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
92781
92852
  contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
92782
- if (!isInteractive || _this.isContentInteractionDisabled(element)) {
92853
+ if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
92854
+ _this.clearContentInteractionState(element);
92855
+ return;
92856
+ }
92857
+ if (!isInteractive) {
92858
+ _this.clearContentInteractionState(element);
92859
+ return;
92860
+ }
92861
+ if (_this.isContentInteractionDisabled(element)) {
92783
92862
  element.dataset.vvfxHtmlInteractionActive = 'false';
92784
92863
  element.style.pointerEvents = 'none';
92785
92864
  return;
92786
92865
  }
92787
- var isElementInteractive = isEditing || activeElement === element;
92866
+ var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
92788
92867
  element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
92789
92868
  element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
92790
92869
  });
92791
92870
  };
92871
+ _proto.clearContentInteractionState = function clearContentInteractionState(element) {
92872
+ delete element.dataset.vvfxHtmlInteractionActive;
92873
+ element.style.pointerEvents = '';
92874
+ };
92792
92875
  _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
92793
92876
  var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
92794
92877
  var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
@@ -95205,8 +95288,7 @@ var SDK = /*#__PURE__*/ function() {
95205
95288
  * @param ignoreClamp 是否忽视约束
95206
95289
  */ _proto.setPageZoom = function setPageZoom(zoom, center, ignoreClamp) {
95207
95290
  assertExist$1(this._pageData);
95208
- this._pageData.property.zoom = zoom;
95209
- this._pageDataUtils.setPageZoom(this._pageData.property.zoom, center, ignoreClamp);
95291
+ this._pageDataUtils.setPageZoom(zoom, center, ignoreClamp);
95210
95292
  this._gestureHandler.render();
95211
95293
  };
95212
95294
  /**